Skip to content

Commit

Permalink
Fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
udnay committed Jan 9, 2025
1 parent 9ae67e3 commit c6c135e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions internal/files/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ func HardlinkDir(olddir, newdir string) error {

fastwalkConf := fastwalk.DefaultConfig.Copy()
fastwalkConf.Sort = fastwalk.SortDirsFirst
dirPermissions := rootInfo.Mode()

return fastwalk.Walk(fastwalkConf, olddir, func(oldpath string, d os.DirEntry, err error) error {
if err != nil {
Expand All @@ -223,8 +222,18 @@ func HardlinkDir(olddir, newdir string) error {

newpath := filepath.Join(newdir, strings.TrimPrefix(oldpath, olddir))

// The new "root" already exists so don't recreate it
if newpath == newdir {
return nil
}

if d.IsDir() {
err = os.Mkdir(newpath, dirPermissions)
info, err := d.Info()
if err != nil {
return fmt.Errorf("unable to get directory info %v: %w", oldpath, err)
}

err = os.Mkdir(newpath, info.Mode())
if err != nil {
return fmt.Errorf("cannot create dir %v: %w", newpath, err)
}
Expand Down

0 comments on commit c6c135e

Please sign in to comment.