mirror of
https://github.com/borgbackup/borg.git
synced 2025-03-03 18:27:01 +00:00
refactor upgrade progress indication code to use ProgressIndicatorPercent
This commit is contained in:
parent
7a1316cb79
commit
fe6916bd22
1 changed files with 6 additions and 8 deletions
|
@ -7,7 +7,7 @@
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from .helpers import get_keys_dir, get_cache_dir
|
from .helpers import get_keys_dir, get_cache_dir, ProgressIndicatorPercent
|
||||||
from .locking import UpgradableLock
|
from .locking import UpgradableLock
|
||||||
from .repository import Repository, MAGIC
|
from .repository import Repository, MAGIC
|
||||||
from .key import KeyfileKey, KeyfileNotFoundError
|
from .key import KeyfileKey, KeyfileNotFoundError
|
||||||
|
@ -65,17 +65,15 @@ def convert_segments(segments, dryrun=True, inplace=False):
|
||||||
luckily the magic string length didn't change so we can just
|
luckily the magic string length didn't change so we can just
|
||||||
replace the 8 first bytes of all regular files in there."""
|
replace the 8 first bytes of all regular files in there."""
|
||||||
logger.info("converting %d segments..." % len(segments))
|
logger.info("converting %d segments..." % len(segments))
|
||||||
i = 0
|
segment_count = len(segments)
|
||||||
for filename in segments:
|
pi = ProgressIndicatorPercent(total=segment_count, msg="Converting segments %3.0f%%", same_line=True)
|
||||||
i += 1
|
for i, filename in enumerate(segments):
|
||||||
print("\rconverting segment %d/%d, %.2f%% done (%s)"
|
pi.show(i)
|
||||||
% (i, len(segments), 100*float(i)/len(segments), filename),
|
|
||||||
end='', file=sys.stderr)
|
|
||||||
if dryrun:
|
if dryrun:
|
||||||
time.sleep(0.001)
|
time.sleep(0.001)
|
||||||
else:
|
else:
|
||||||
AtticRepositoryUpgrader.header_replace(filename, ATTIC_MAGIC, MAGIC, inplace=inplace)
|
AtticRepositoryUpgrader.header_replace(filename, ATTIC_MAGIC, MAGIC, inplace=inplace)
|
||||||
print(file=sys.stderr)
|
pi.finish()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def header_replace(filename, old_magic, new_magic, inplace=True):
|
def header_replace(filename, old_magic, new_magic, inplace=True):
|
||||||
|
|
Loading…
Reference in a new issue