1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-02-22 06:01:54 +00:00

use same finalizing code for hardlink masters and slaves

hardlink slaves get a precomputed size attribute now.
This commit is contained in:
Thomas Waldmann 2017-03-26 06:15:36 +02:00
parent a206a85890
commit e5d094d0ce

View file

@ -934,14 +934,11 @@ def process_file(self, path, st, cache, ignore_inode=False):
source = self.hard_links.get((st.st_ino, st.st_dev))
if source is not None:
item.source = source
item.update(self.stat_attrs(st, path))
self.add_item(item)
status = 'h' # regular file, hardlink (to already seen inodes)
return status
else:
hardlink_master = True
is_special_file = is_special(st.st_mode)
if True:
if not hardlinked or hardlink_master:
if not is_special_file:
path_hash = self.key.id_hash(safe_encode(os.path.join(self.cwd, path)))
ids = cache.file_known_and_unchanged(path_hash, st, ignore_inode)
@ -979,15 +976,15 @@ def process_file(self, path, st, cache, ignore_inode=False):
# block or char device will change without its mtime/size/inode changing.
cache.memorize_file(path_hash, st, [c.id for c in item.chunks])
status = status or 'M' # regular file, modified (if not 'A' already)
self.stats.nfiles += 1
item.update(self.stat_attrs(st, path))
item.get_size(memorize=True)
if is_special_file:
# we processed a special file like a regular file. reflect that in mode,
# so it can be extracted / accessed in FUSE mount like a regular file:
item.mode = stat.S_IFREG | stat.S_IMODE(item.mode)
self.stats.nfiles += 1
self.add_item(item)
if hardlinked and hardlink_master:
if hardlink_master:
# Add the hard link reference *after* the file has been added to the archive.
self.hard_links[st.st_ino, st.st_dev] = safe_path
return status