Merge "Revert "Change symlink_forest to use relative symlinks."" into main

This commit is contained in:
Sebastian Pickl
2023-09-12 18:53:47 +00:00
committed by Gerrit Code Review
6 changed files with 4 additions and 164 deletions

View File

@@ -190,20 +190,10 @@ func readdirToMap(dir string) map[string]os.FileInfo {
// Creates a symbolic link at dst pointing to src
func symlinkIntoForest(topdir, dst, src string) uint64 {
// b/259191764 - Make all symlinks relative
dst = shared.JoinPath(topdir, dst)
src = shared.JoinPath(topdir, src)
basePath := filepath.Dir(dst)
var dstPath string
srcPath, err := filepath.Rel(basePath, src)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to find relative path for symlinking: %s\n", err)
os.Exit(1)
} else {
dstPath = dst
}
srcPath := shared.JoinPath(topdir, src)
dstPath := shared.JoinPath(topdir, dst)
// Check whether a symlink already exists.
// Check if a symlink already exists.
if dstInfo, err := os.Lstat(dstPath); err != nil {
if !os.IsNotExist(err) {
fmt.Fprintf(os.Stderr, "Failed to lstat '%s': %s", dst, err)