Skip to content

Commit 0586cc7

Browse files
committed
compact: report progress after each unit so it reaches 100%
1 parent 78b8bba commit 0586cc7

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/borg/archiver/compact_cmd.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ def use_it(id):
131131
)
132132
total_size, total_files = 0, 0
133133
for i, info in enumerate(archive_infos):
134-
pi.show(i)
135134
logger.info(
136135
f"Analyzing archive {info.name} {info.ts.astimezone()} {bin_to_hex(info.id)} ({i + 1}/{num_archives})"
137136
)
@@ -149,6 +148,7 @@ def use_it(id):
149148
for id, size in item.chunks:
150149
total_size += size # original, uncompressed file content size
151150
use_it(id)
151+
pi.show(i + 1) # report after each archive, so the last one lands on 100%
152152
pi.finish()
153153
return missing_chunks, total_files, total_size, num_archives
154154

@@ -158,7 +158,7 @@ def report_and_delete(self):
158158
for id in sorted(self.missing_chunks):
159159
logger.debug(f"Missing object {bin_to_hex(id)}")
160160
set_ec(EXIT_ERROR)
161-
if not self.dry_run: # nuking soft-deleted archives mutates the manifest; skip on a dry run
161+
if not self.dry_run: # nuking removes the soft-deleted archives from the archives directory; skip on a dry run
162162
logger.info("Cleaning archives directory from soft-deleted archives...")
163163
archive_infos = self.manifest.archives.list(sort_by=["ts"], deleted=True)
164164
for archive_info in archive_infos:
@@ -262,15 +262,15 @@ def compact_packs(self):
262262
)
263263
progress = 0
264264
for pid in drop_packs:
265-
pi.show(progress)
266-
progress += 1
267265
self.repository.store_delete("packs/" + bin_to_hex(pid))
266+
progress += 1
267+
pi.show(progress) # report after the work, so the final pack lands on 100%
268268
for id in forget:
269269
del self.chunks[id] # their pack file is gone, so drop their index entries too
270270
for pid in rewrite_packs:
271-
pi.show(progress)
272-
progress += 1
273271
self.repository.compact_pack(pid, keep_ids=keep[pid], drop_ids=drop[pid]) # helper owns index update
272+
progress += 1
273+
pi.show(progress)
274274
pi.finish()
275275

276276

0 commit comments

Comments
 (0)