Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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