@@ -3,6 +3,7 @@ package sync
33import (
44 "archive/tar"
55 "compress/gzip"
6+ "github.com/loft-sh/devspace/pkg/util/fsutil"
67 "io"
78 "io/ioutil"
89 "os"
@@ -283,8 +284,8 @@ func (a *Archiver) AddToArchive(relativePath string) error {
283284}
284285
285286func (a * Archiver ) tarFolder (target * FileInformation , targetStat os.FileInfo ) error {
286- filepath := path .Join (a .basePath , target .Name )
287- files , err := ioutil .ReadDir (filepath )
287+ filePath := path .Join (a .basePath , target .Name )
288+ files , err := ioutil .ReadDir (filePath )
288289 if err != nil {
289290 // config.Logf("[Upstream] Couldn't read dir %s: %s\n", filepath, err.Error())
290291 return nil
@@ -294,7 +295,7 @@ func (a *Archiver) tarFolder(target *FileInformation, targetStat os.FileInfo) er
294295 // check if not excluded
295296 if a .ignoreMatcher == nil || ! a .ignoreMatcher .RequireFullScan () || ! a .ignoreMatcher .Matches (target .Name , true ) {
296297 // Case empty directory
297- hdr , _ := tar .FileInfoHeader (targetStat , filepath )
298+ hdr , _ := tar .FileInfoHeader (targetStat , filePath )
298299 hdr .Uid = 0
299300 hdr .Gid = 0
300301 hdr .Mode = fillGo18FileTypeBits (int64 (chmodTarEntry (os .FileMode (hdr .Mode ))), targetStat )
@@ -308,6 +309,10 @@ func (a *Archiver) tarFolder(target *FileInformation, targetStat os.FileInfo) er
308309 }
309310
310311 for _ , f := range files {
312+ if fsutil .IsRecursiveSymlink (f , path .Join (filePath , f .Name ())) {
313+ continue
314+ }
315+
311316 if err := a .AddToArchive (path .Join (target .Name , f .Name ())); err != nil {
312317 return errors .Wrap (err , "recursive tar " + f .Name ())
313318 }
@@ -325,7 +330,7 @@ func (a *Archiver) tarFile(target *FileInformation, targetStat os.FileInfo) erro
325330 }
326331
327332 targetStat , err = os .Stat (filepath )
328- if err != nil {
333+ if err != nil || targetStat . IsDir () {
329334 // We ignore open file and just treat it as okay
330335 return nil
331336 }
0 commit comments