Skip to content

Commit

Permalink
copier: retain symlink target w/ follow-link
Browse files Browse the repository at this point in the history
[NO NEW TESTS NEEDED]

Signed-off-by: danishprakash <[email protected]>
  • Loading branch information
danishprakash committed Jun 6, 2023
1 parent aa6a281 commit b58a762
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion copier/copier.go
Original file line number Diff line number Diff line change
Expand Up @@ -1307,7 +1307,17 @@ 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, err = os.Readlink(item)
if err != nil {
return err
}
}
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 b58a762

Please sign in to comment.