1
0
Fork 0
mirror of https://github.com/restic/restic.git synced 2024-12-22 07:43:03 +00:00

Merge pull request #5061 from MichaelEischer/fix-timestamp-restore-windows

fs: fix restoring timestamps on older Windows versions for long paths
This commit is contained in:
Michael Eischer 2024-10-16 20:47:17 +02:00 committed by GitHub
commit e91a456656
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 3 deletions

View file

@ -0,0 +1,9 @@
Bugfix: Correctly restore timestamp on long filepaths on old Windows versions
The `restore` command did not restore timestamps on file paths longer than 256
characters on Windows versions before Windows 10 1607.
This issue is now resolved.
https://github.com/restic/restic/issues/1843
https://github.com/restic/restic/pull/5061

View file

@ -303,7 +303,7 @@ func nodeRestoreTimestamps(node *restic.Node, path string) error {
return nodeRestoreSymlinkTimestamps(path, utimes)
}
if err := syscall.UtimesNano(path, utimes[:]); err != nil {
if err := syscall.UtimesNano(fixpath(path), utimes[:]); err != nil {
return errors.Wrap(err, "UtimesNano")
}

View file

@ -202,7 +202,7 @@ func genericAttributesToWindowsAttrs(attrs map[restic.GenericAttributeType]json.
// restoreCreationTime gets the creation time from the data and sets it to the file/folder at
// the specified path.
func restoreCreationTime(path string, creationTime *syscall.Filetime) (err error) {
pathPointer, err := syscall.UTF16PtrFromString(path)
pathPointer, err := syscall.UTF16PtrFromString(fixpath(path))
if err != nil {
return err
}
@ -223,7 +223,7 @@ func restoreCreationTime(path string, creationTime *syscall.Filetime) (err error
// restoreFileAttributes gets the File Attributes from the data and sets them to the file/folder
// at the specified path.
func restoreFileAttributes(path string, fileAttributes *uint32) (err error) {
pathPointer, err := syscall.UTF16PtrFromString(path)
pathPointer, err := syscall.UTF16PtrFromString(fixpath(path))
if err != nil {
return err
}