Skip to content

Commit

Permalink
copier: retain symlink target w/ follow-link
Browse files Browse the repository at this point in the history
Signed-off-by: danishprakash <[email protected]>
  • Loading branch information
danishprakash committed Apr 3, 2023
1 parent 40dff19 commit 07cefb9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion copier/copier.go
Original file line number Diff line number Diff line change
Expand Up @@ -1307,7 +1307,14 @@ func copierHandlerGet(bulkWriter io.Writer, req request, pm *fileutils.PatternMa
// cases where this was a symlink that we
// dereferenced, be sure to use the name of the
// link.
if err := copierHandlerGetOne(info, "", filepath.Base(queue[i]), item, req.GetOptions, tw, hardlinkChecker, idMappings); err != nil {

// If following link, pass symlink target for
// the link to be generated on the destination.
var symlinkTarget string
if req.GetOptions.NoDerefSymlinks && info.Mode()&os.ModeType == os.ModeSymlink {
symlinkTarget = item
}
if err := copierHandlerGetOne(info, symlinkTarget, filepath.Base(queue[i]), item, req.GetOptions, tw, hardlinkChecker, idMappings); err != nil {
if req.GetOptions.IgnoreUnreadable && errorIsPermission(err) {
continue
}
Expand Down

0 comments on commit 07cefb9

Please sign in to comment.