Skip to content

Commit 45cf871

Browse files
committed
361: Keep processing directory entries if a symlinked directory is found. Also removed a redundant check of the err value.
1 parent e8a2a6e commit 45cf871

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

internal/provider/tar_archiver.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,6 @@ func (a *TarArchiver) createWalkFunc(basePath, indirname string, opts ArchiveDir
141141
return nil
142142
}
143143

144-
if err != nil {
145-
return err
146-
}
147-
148144
if info.Mode()&os.ModeSymlink == os.ModeSymlink {
149145
realPath, err := filepath.EvalSymlinks(path)
150146
if err != nil {
@@ -160,7 +156,10 @@ func (a *TarArchiver) createWalkFunc(basePath, indirname string, opts ArchiveDir
160156
if !opts.ExcludeSymlinkDirectories {
161157
return filepath.Walk(realPath, a.createWalkFunc(archivePath, realPath, opts, isArchiveEmpty, dryRun))
162158
} else {
163-
return filepath.SkipDir
159+
// Don't return filepath.SkipDir here, as the item at the path being processed is a symlink
160+
// and according to https://pkg.go.dev/path/filepath#WalkFunc, returning filepath.SkipDir from WalkFunc
161+
// will skip the parent directory containing the symlink, which is not the desired behavior.
162+
return nil
164163
}
165164
}
166165

0 commit comments

Comments
 (0)