mirror of
https://github.com/borgbackup/borg.git
synced 2025-01-01 12:45:34 +00:00
warn if a file with damaged chunks is extracted, fixes #1299
before 1.0.4/1.0.5 we had no means to tell if a file has been "repaired" with all-zero chunks, but now we can see it if chunks_healthy key is present.
This commit is contained in:
parent
9bfd233ce1
commit
48f112e885
1 changed files with 9 additions and 1 deletions
|
@ -18,7 +18,7 @@
|
|||
from io import BytesIO
|
||||
from . import xattr
|
||||
from .helpers import Error, uid2user, user2uid, gid2group, group2gid, \
|
||||
parse_timestamp, to_localtime, format_time, format_timedelta, \
|
||||
parse_timestamp, to_localtime, format_time, format_timedelta, remove_surrogates, \
|
||||
Manifest, Statistics, decode_dict, make_path_safe, StableDict, int_to_bigint, bigint_to_int, \
|
||||
ProgressIndicatorPercent
|
||||
from .platform import acl_get, acl_set
|
||||
|
@ -344,6 +344,8 @@ def add_file_chunks(chunks):
|
|||
return stats
|
||||
|
||||
def extract_item(self, item, restore_attrs=True, dry_run=False, stdout=False, sparse=False):
|
||||
has_damaged_chunks = b'chunks_healthy' in item
|
||||
|
||||
if dry_run or stdout:
|
||||
if b'chunks' in item:
|
||||
for data in self.pipeline.fetch_many([c[0] for c in item[b'chunks']], is_preloaded=True):
|
||||
|
@ -351,6 +353,9 @@ def extract_item(self, item, restore_attrs=True, dry_run=False, stdout=False, sp
|
|||
sys.stdout.buffer.write(data)
|
||||
if stdout:
|
||||
sys.stdout.buffer.flush()
|
||||
if has_damaged_chunks:
|
||||
logger.warning('File %s has damaged (all-zero) chunks. Try running borg check --repair.' %
|
||||
remove_surrogates(item[b'path']))
|
||||
return
|
||||
|
||||
dest = self.cwd
|
||||
|
@ -397,6 +402,9 @@ def extract_item(self, item, restore_attrs=True, dry_run=False, stdout=False, sp
|
|||
fd.truncate(pos)
|
||||
fd.flush()
|
||||
self.restore_attrs(path, item, fd=fd.fileno())
|
||||
if has_damaged_chunks:
|
||||
logger.warning('File %s has damaged (all-zero) chunks. Try running borg check --repair.' %
|
||||
remove_surrogates(item[b'path']))
|
||||
return
|
||||
with backup_io():
|
||||
# No repository access beyond this point.
|
||||
|
|
Loading…
Reference in a new issue