Merge pull request #191 from restic/fix-189

Fix restoring symlink timestamps for linux
This commit is contained in:
Alexander Neumann 2015-05-17 14:26:54 +02:00
commit cf37b619fd
6 changed files with 170 additions and 13 deletions

24
node.go
View file

@ -146,13 +146,11 @@ func (node Node) restoreMetadata(path string) error {
return errors.Annotate(err, "Lchown")
}
if node.Type == "symlink" {
return nil
}
err = os.Chmod(path, node.Mode)
if err != nil {
return errors.Annotate(err, "Chmod")
if node.Type != "symlink" {
err = os.Chmod(path, node.Mode)
if err != nil {
return errors.Annotate(err, "Chmod")
}
}
if node.Type != "dir" {
@ -166,12 +164,20 @@ func (node Node) restoreMetadata(path string) error {
}
func (node Node) RestoreTimestamps(path string) error {
var utimes = []syscall.Timespec{
var utimes = [...]syscall.Timespec{
syscall.NsecToTimespec(node.AccessTime.UnixNano()),
syscall.NsecToTimespec(node.ModTime.UnixNano()),
}
if err := syscall.UtimesNano(path, utimes); err != nil {
if node.Type == "symlink" {
if err := node.restoreSymlinkTimestamps(path, utimes); err != nil {
return err
}
return nil
}
if err := syscall.UtimesNano(path, utimes[:]); err != nil {
return errors.Annotate(err, "UtimesNano")
}