Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve attributes when moving across devices #1482

Merged
merged 1 commit into from
Nov 6, 2023
Merged
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
8 changes: 4 additions & 4 deletions copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ func copySize(srcs []string) (int64, error) {
return total, nil
}

func copyFile(src, dst string, info os.FileInfo, nums chan int64) error {
func copyFile(src, dst string, preserve []string, info os.FileInfo, nums chan int64) error {
var dst_mode os.FileMode = 0666
preserve_timestamps := false
for _, s := range gOpts.preserve {
for _, s := range preserve {
switch s {
case "timestamps":
preserve_timestamps = true
Expand Down Expand Up @@ -98,7 +98,7 @@ func copyFile(src, dst string, info os.FileInfo, nums chan int64) error {
return nil
}

func copyAll(srcs []string, dstDir string) (nums chan int64, errs chan error) {
func copyAll(srcs []string, dstDir string, preserve []string) (nums chan int64, errs chan error) {
nums = make(chan int64, 1024)
errs = make(chan error, 1024)

Expand Down Expand Up @@ -149,7 +149,7 @@ func copyAll(srcs []string, dstDir string) (nums chan int64, errs chan error) {
}
nums <- info.Size()
} else {
if err := copyFile(path, newPath, info, nums); err != nil {
if err := copyFile(path, newPath, preserve, info, nums); err != nil {
errs <- fmt.Errorf("copy: %s", err)
}
}
Expand Down
4 changes: 2 additions & 2 deletions nav.go
Original file line number Diff line number Diff line change
Expand Up @@ -1320,7 +1320,7 @@ func (nav *nav) copyAsync(app *app, srcs []string, dstDir string) {

nav.copyTotalChan <- total

nums, errs := copyAll(srcs, dstDir)
nums, errs := copyAll(srcs, dstDir, gOpts.preserve)

errCount := 0
loop:
Expand Down Expand Up @@ -1415,7 +1415,7 @@ func (nav *nav) moveAsync(app *app, srcs []string, dstDir string) {

nav.copyTotalChan <- total

nums, errs := copyAll([]string{src}, dstDir)
nums, errs := copyAll([]string{src}, dstDir, []string{"mode", "timestamps"})

oldCount := errCount
loop:
Expand Down