restic: restore timestamps after extended attributes

restoring the xattr containing resource forks on macOS apparently
modifies the file modification timestamps. Thus, restore the timestamp
after xattrs.
This commit is contained in:
Michael Eischer 2024-08-15 21:17:49 +02:00
parent a8efaee03c
commit 2e55209b34
2 changed files with 14 additions and 7 deletions

View file

@ -0,0 +1,7 @@
Bugfix: Correctly restore timestamp for files with resource forks on macOS
On macOS, timestamps were incorrectly restored for files with resource forks.
This has been fixed.
https://github.com/restic/restic/issues/4969
https://github.com/restic/restic/pull/5006

View file

@ -249,13 +249,6 @@ func (node Node) restoreMetadata(path string, warn func(msg string)) error {
firsterr = errors.WithStack(err)
}
if err := node.RestoreTimestamps(path); err != nil {
debug.Log("error restoring timestamps for dir %v: %v", path, err)
if firsterr == nil {
firsterr = err
}
}
if err := node.restoreExtendedAttributes(path); err != nil {
debug.Log("error restoring extended attributes for %v: %v", path, err)
if firsterr == nil {
@ -270,6 +263,13 @@ func (node Node) restoreMetadata(path string, warn func(msg string)) error {
}
}
if err := node.RestoreTimestamps(path); err != nil {
debug.Log("error restoring timestamps for %v: %v", path, err)
if firsterr == nil {
firsterr = err
}
}
// Moving RestoreTimestamps and restoreExtendedAttributes calls above as for readonly files in windows
// calling Chmod below will no longer allow any modifications to be made on the file and the
// calls above would fail.