func (node Node) restoreMetadata(path string) error { var err error err = lchown(path, int(node.UID), int(node.GID)) if err != nil { return errors.Wrap(err, "Lchown") } if node.Type != "symlink" { err = fs.Chmod(path, node.Mode) if err != nil { return errors.Wrap(err, "Chmod") } } if node.Type != "dir" { err = node.RestoreTimestamps(path) if err != nil { debug.Log("error restoring timestamps for dir %v: %v", path, err) return err } } return nil }
// Remove removes the blob with the given name and type. func (b *Local) Remove(t restic.FileType, name string) error { debug.Log("Remove %v %v", t, name) fn := filename(b.p, t, name) // reset read-only flag err := fs.Chmod(fn, 0666) if err != nil { return errors.Wrap(err, "Chmod") } return fs.Remove(fn) }
// set file to readonly func setNewFileMode(f string, fi os.FileInfo) error { return fs.Chmod(f, fi.Mode()&os.FileMode(^uint32(0222))) }