1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-01-03 05:35:58 +00:00

compact: fix dsize computation if wanted chunks are present in repo

This commit is contained in:
Thomas Waldmann 2024-08-31 02:44:04 +02:00
parent 551834acfc
commit 86dc673649
No known key found for this signature in database
GPG key ID: 243ACFA951F78E01

View file

@ -4,7 +4,7 @@
from ._common import with_repository
from ..archive import Archive
from ..constants import * # NOQA
from ..helpers import set_ec, EXIT_WARNING, EXIT_ERROR, format_file_size
from ..helpers import set_ec, EXIT_WARNING, EXIT_ERROR, format_file_size, bin_to_hex
from ..helpers import ProgressIndicatorPercent
from ..manifest import Manifest
from ..remote import RemoteRepository
@ -133,7 +133,14 @@ def report_and_delete(self):
logger.info(
f"Source data size was {format_file_size(self.total_size, precision=0)} in {self.total_files} files."
)
dsize = sum(self.used_chunks[id] for id in self.repository_chunks)
dsize = 0
for id in self.repository_chunks:
if id in self.used_chunks:
dsize += self.used_chunks[id]
elif id in self.wanted_chunks:
dsize += self.wanted_chunks[id]
else:
raise KeyError(bin_to_hex(id))
logger.info(f"Repository size is {format_file_size(self.repository_size, precision=0)} in {count} objects.")
if self.total_size != 0:
logger.info(f"Space reduction factor due to deduplication: {dsize / self.total_size:.3f}")