Skip to content
Open
9 changes: 4 additions & 5 deletions internal/provider/tar_archiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,6 @@ func (a *TarArchiver) createWalkFunc(basePath, indirname string, opts ArchiveDir
return nil
}

if err != nil {
return err
}

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

Expand Down
5 changes: 4 additions & 1 deletion internal/provider/zip_archiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,10 @@ func (a *ZipArchiver) createWalkFunc(basePath, indirname string, opts ArchiveDir
if !opts.ExcludeSymlinkDirectories {
return filepath.Walk(realPath, a.createWalkFunc(archivePath, realPath, opts, isArchiveEmpty, dryRun))
} else {
return filepath.SkipDir
// Don't return filepath.SkipDir here, as the item at the path being processed is a symlink
// and according to https://pkg.go.dev/path/filepath#WalkFunc, returning filepath.SkipDir from WalkFunc
// will skip the parent directory containing the symlink, which is not the desired behavior.
return nil
}
}

Expand Down