diff --git a/borg/archive.py b/borg/archive.py index 3cc9c2c22..83ed4b3a8 100644 --- a/borg/archive.py +++ b/borg/archive.py @@ -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.