mirror of https://github.com/borgbackup/borg.git
Defer directory attr restoration to avoid permission problems
This commit is contained in:
parent
ddade8384c
commit
e0615df187
|
@ -139,7 +139,7 @@ class Archive(object):
|
|||
cache.rollback()
|
||||
return stats
|
||||
|
||||
def extract_item(self, item, dest=None, start_cb=None):
|
||||
def extract_item(self, item, dest=None, start_cb=None, restore_attrs=True):
|
||||
dest = dest or os.getcwdu()
|
||||
dir_stat_queue = []
|
||||
assert item['path'][0] not in ('/', '\\', ':')
|
||||
|
@ -148,7 +148,8 @@ class Archive(object):
|
|||
if stat.S_ISDIR(mode):
|
||||
if not os.path.exists(path):
|
||||
os.makedirs(path)
|
||||
self.restore_attrs(path, item)
|
||||
if restore_attrs:
|
||||
self.restore_attrs(path, item)
|
||||
elif stat.S_ISFIFO(mode):
|
||||
if not os.path.exists(os.path.dirname(path)):
|
||||
os.makedirs(os.path.dirname(path))
|
||||
|
|
|
@ -117,9 +117,11 @@ class Archiver(object):
|
|||
def extract_cb(item):
|
||||
if exclude_path(item['path'], args.patterns):
|
||||
return
|
||||
archive.extract_item(item, args.dest, start_cb)
|
||||
if stat.S_ISDIR(item['mode']):
|
||||
dirs.append(item)
|
||||
archive.extract_item(item, args.dest, start_cb, restore_attrs=False)
|
||||
else:
|
||||
archive.extract_item(item, args.dest, start_cb)
|
||||
if dirs and not item['path'].startswith(dirs[-1]['path']):
|
||||
# Extract directories twice to make sure mtime is correctly restored
|
||||
archive.extract_item(dirs.pop(-1), args.dest)
|
||||
|
|
Loading…
Reference in New Issue