mirror of
https://github.com/borgbackup/borg.git
synced 2025-02-25 15:33:39 +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,15 +653,18 @@ def save(self, name=None, comment=None, timestamp=None, stats=None, additional_m
|
|||
"time_end": end.isoformat(timespec="microseconds"),
|
||||
"chunker_params": self.chunker_params,
|
||||
}
|
||||
if stats is not None:
|
||||
metadata.update(
|
||||
{
|
||||
"size": stats.osize,
|
||||
"nfiles": stats.nfiles,
|
||||
"size_parts": stats.osize_parts,
|
||||
"nfiles_parts": stats.nfiles_parts,
|
||||
}
|
||||
)
|
||||
# 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(
|
||||
{
|
||||
"size": stats.osize,
|
||||
"nfiles": stats.nfiles,
|
||||
"size_parts": stats.osize_parts,
|
||||
"nfiles_parts": stats.nfiles_parts,
|
||||
}
|
||||
)
|
||||
metadata.update(additional_metadata or {})
|
||||
metadata = ArchiveItem(metadata)
|
||||
data = self.key.pack_and_authenticate_metadata(metadata.as_dict(), context=b"archive")
|
||||
|
@ -2320,9 +2323,7 @@ def save(self, archive, target, comment=None, replace_original=True):
|
|||
"recreate_cmdline": sys.argv,
|
||||
}
|
||||
|
||||
target.save(
|
||||
comment=comment, timestamp=self.timestamp, stats=target.stats, additional_metadata=additional_metadata
|
||||
)
|
||||
target.save(comment=comment, timestamp=self.timestamp, additional_metadata=additional_metadata)
|
||||
if replace_original:
|
||||
archive.delete(Statistics(), progress=self.progress)
|
||||
target.rename(archive.name)
|
||||
|
|
|
@ -190,7 +190,7 @@ def create_inner(archive, cache, fso):
|
|||
# we already have a checkpoint archive in this case.
|
||||
self.print_error("Got Ctrl-C / SIGINT.")
|
||||
else:
|
||||
archive.save(comment=args.comment, timestamp=args.timestamp, stats=archive.stats)
|
||||
archive.save(comment=args.comment, timestamp=args.timestamp)
|
||||
args.stats |= args.json
|
||||
if args.stats:
|
||||
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))
|
||||
if not dry_run:
|
||||
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(
|
||||
f"{name}: finished. "
|
||||
f"transfer_size: {format_file_size(transfer_size)} "
|
||||
|
|
Loading…
Reference in a new issue