Skip to content

Commit 18a1c09

Browse files
committed
Remove unreachable block in fs path cleanup
The block checking for the root as a prefix of an absolute link is unnecessary since the end path always gets joined with the root. In the case where the symlink path is prefixed with the root, this should be considered coincidental and the unit tests already show that the root gets correctly applied to absolute links. Additionally inside this block there is a bug causing in incorrect truncation of the path which would only manifest itself in this rare coincidental case. Signed-off-by: Derek McGowan <[email protected]>
1 parent 508d86a commit 18a1c09

1 file changed

Lines changed: 0 additions & 6 deletions

File tree

fs/path.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -248,12 +248,6 @@ func walkLink(root, path string, linksWalked *int) (newpath string, islink bool,
248248
if err != nil {
249249
return "", false, err
250250
}
251-
if filepath.IsAbs(newpath) && strings.HasPrefix(newpath, root) {
252-
newpath = newpath[:len(root)]
253-
if !strings.HasPrefix(newpath, "/") {
254-
newpath = "/" + newpath
255-
}
256-
}
257251
*linksWalked++
258252
return newpath, true, nil
259253
}

0 commit comments

Comments
 (0)