Skip to content

Commit

Permalink
Fix issue preventing includeed sources from being mapped to the rep…
Browse files Browse the repository at this point in the history
…o root

Signed-off-by: Fred Heinecke <[email protected]>
  • Loading branch information
solidDoWant committed Nov 1, 2024
1 parent 53868f7 commit f00bb36
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 1 addition & 4 deletions internal/fs/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ var (
)

// CopyDir recursively copies a directory tree, attempting to preserve permissions.
// Source directory must exist, destination directory must *not* exist.
// Source directory must exist.
func CopyDir(src, dst string) error {
src = filepath.Clean(src)
dst = filepath.Clean(dst)
Expand All @@ -83,9 +83,6 @@ func CopyDir(src, dst string) error {
if err != nil && !os.IsNotExist(err) {
return err
}
if err == nil {
return errDstExist
}

if err = os.MkdirAll(dst, fi.Mode()); err != nil {
return fmt.Errorf("cannot mkdir %s: %w", dst, err)
Expand Down
4 changes: 3 additions & 1 deletion internal/fs/rename.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ func renameFallback(err error, src, dst string) error {
// copy if we detect that case. syscall.EXDEV is the common name for the
// cross device link error which has varying output text across different
// operating systems.
// Rename may also fail if the directory already exists, which occurs when
// mapping to the root of another repo. Copy should still succeed.
terr, ok := err.(*os.LinkError)
if !ok {
return err
} else if terr.Err != syscall.EXDEV {
} else if terr.Err != syscall.EXDEV && terr.Err != syscall.EEXIST {
return fmt.Errorf("link error: cannot rename %s to %s: %w", src, dst, terr)
}

Expand Down

0 comments on commit f00bb36

Please sign in to comment.