mirror of
https://github.com/borgbackup/borg.git
synced 2025-02-26 07:53:58 +00:00
archive.save(): always use metadata from stats, fixes #7072
e.g. nfiles, size, etc. fixes: - checkpoint archives did not have this metadata yet - borg import-tar did not have this metadata yet
This commit is contained in:
parent
16e8213716
commit
2e83d18d35
3 changed files with 15 additions and 14 deletions
|
@ -653,7 +653,10 @@ def save(self, name=None, comment=None, timestamp=None, stats=None, additional_m
|
||||||
"time_end": end.isoformat(timespec="microseconds"),
|
"time_end": end.isoformat(timespec="microseconds"),
|
||||||
"chunker_params": self.chunker_params,
|
"chunker_params": self.chunker_params,
|
||||||
}
|
}
|
||||||
if stats is not None:
|
# we always want to create archives with the addtl. metadata (nfiles, etc.),
|
||||||
|
# because borg info relies on them. so, either use the given stats (from args)
|
||||||
|
# or fall back to self.stats if it was not given.
|
||||||
|
stats = stats or self.stats
|
||||||
metadata.update(
|
metadata.update(
|
||||||
{
|
{
|
||||||
"size": stats.osize,
|
"size": stats.osize,
|
||||||
|
@ -2320,9 +2323,7 @@ def save(self, archive, target, comment=None, replace_original=True):
|
||||||
"recreate_cmdline": sys.argv,
|
"recreate_cmdline": sys.argv,
|
||||||
}
|
}
|
||||||
|
|
||||||
target.save(
|
target.save(comment=comment, timestamp=self.timestamp, additional_metadata=additional_metadata)
|
||||||
comment=comment, timestamp=self.timestamp, stats=target.stats, additional_metadata=additional_metadata
|
|
||||||
)
|
|
||||||
if replace_original:
|
if replace_original:
|
||||||
archive.delete(Statistics(), progress=self.progress)
|
archive.delete(Statistics(), progress=self.progress)
|
||||||
target.rename(archive.name)
|
target.rename(archive.name)
|
||||||
|
|
|
@ -190,7 +190,7 @@ def create_inner(archive, cache, fso):
|
||||||
# we already have a checkpoint archive in this case.
|
# we already have a checkpoint archive in this case.
|
||||||
self.print_error("Got Ctrl-C / SIGINT.")
|
self.print_error("Got Ctrl-C / SIGINT.")
|
||||||
else:
|
else:
|
||||||
archive.save(comment=args.comment, timestamp=args.timestamp, stats=archive.stats)
|
archive.save(comment=args.comment, timestamp=args.timestamp)
|
||||||
args.stats |= args.json
|
args.stats |= args.json
|
||||||
if args.stats:
|
if args.stats:
|
||||||
if args.json:
|
if args.json:
|
||||||
|
|
|
@ -100,7 +100,7 @@ def do_transfer(self, args, *, repository, manifest, cache, other_repository=Non
|
||||||
archive.add_item(upgrader.upgrade_item(item=item))
|
archive.add_item(upgrader.upgrade_item(item=item))
|
||||||
if not dry_run:
|
if not dry_run:
|
||||||
additional_metadata = upgrader.upgrade_archive_metadata(metadata=other_archive.metadata)
|
additional_metadata = upgrader.upgrade_archive_metadata(metadata=other_archive.metadata)
|
||||||
archive.save(stats=archive.stats, additional_metadata=additional_metadata)
|
archive.save(additional_metadata=additional_metadata)
|
||||||
print(
|
print(
|
||||||
f"{name}: finished. "
|
f"{name}: finished. "
|
||||||
f"transfer_size: {format_file_size(transfer_size)} "
|
f"transfer_size: {format_file_size(transfer_size)} "
|
||||||
|
|
Loading…
Reference in a new issue