From 5dada30d9e47fa2e7318f83de1575ce77cee7ba4 Mon Sep 17 00:00:00 2001 From: TW Date: Sun, 20 Oct 2024 13:35:45 +0200 Subject: [PATCH] borg2: support >= b10, drop support for < b10. By @ThomasWaldmann (#2102) - new repo-* commands (previously: r*) - some stats are gone --- src/vorta/borg/_compatibility.py | 2 +- src/vorta/borg/borg_job.py | 2 +- src/vorta/borg/create.py | 4 ++-- src/vorta/borg/info_repo.py | 2 +- src/vorta/borg/init.py | 2 +- src/vorta/borg/list_repo.py | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/vorta/borg/_compatibility.py b/src/vorta/borg/_compatibility.py index bf2a01b0..327a83a6 100644 --- a/src/vorta/borg/_compatibility.py +++ b/src/vorta/borg/_compatibility.py @@ -7,7 +7,7 @@ 'DIFF_JSON_LINES': parse_version('1.1.16'), 'COMPACT_SUBCOMMAND': parse_version('1.2.0a1'), 'V122': parse_version('1.2.2'), - 'V2': parse_version('2.0.0b1'), + 'V2': parse_version('2.0.0b10'), # add new version-checks here. } diff --git a/src/vorta/borg/borg_job.py b/src/vorta/borg/borg_job.py index 9cf6a155..b66acc2d 100644 --- a/src/vorta/borg/borg_job.py +++ b/src/vorta/borg/borg_job.py @@ -294,7 +294,7 @@ def read_async(fd): f"{translate('BorgJob','Files')}: {parsed['nfiles']}, " f"{translate('BorgJob','Original')}: {pretty_bytes(parsed['original_size'])}, " # f"{translate('BorgJob','Compressed')}: {pretty_bytes(parsed['compressed_size'])}, " - f"{translate('BorgJob','Deduplicated')}: {pretty_bytes(parsed['deduplicated_size'])}" # noqa: E501 + f"{translate('BorgJob','Deduplicated')}: {pretty_bytes(parsed.get('deduplicated_size', 0))}" # noqa: E501 ) self.app.backup_progress_event.emit(f"[{self.params['profile_name']}] {msg}") except json.decoder.JSONDecodeError: diff --git a/src/vorta/borg/create.py b/src/vorta/borg/create.py index b1601137..171265c0 100644 --- a/src/vorta/borg/create.py +++ b/src/vorta/borg/create.py @@ -27,12 +27,12 @@ def process_result(self, result): 'time': dt.fromisoformat(result['data']['archive']['start']).replace(tzinfo=None), 'repo': result['params']['repo_id'], 'duration': result['data']['archive']['duration'], - 'size': result['data']['archive']['stats']['deduplicated_size'], + 'size': result['data']['archive']['stats'].get('deduplicated_size', 0), 'trigger': result['params'].get('category', 'user'), }, ) new_archive.save() - if 'cache' in result['data'] and created: + if created and 'cache' in result['data'] and 'stats' in result['data']['cache']: stats = result['data']['cache']['stats'] repo = RepoModel.get(id=result['params']['repo_id']) repo.total_size = stats['total_size'] diff --git a/src/vorta/borg/info_repo.py b/src/vorta/borg/info_repo.py index 4bbb870b..237b3b06 100644 --- a/src/vorta/borg/info_repo.py +++ b/src/vorta/borg/info_repo.py @@ -30,7 +30,7 @@ def prepare(cls, params): ret['ok'] = False # Set back to false, so we can do our own checks here. if borg_compat.check('V2'): - cmd = ["borg", "rinfo", "--info", "--json", "--log-json", "-r"] + cmd = ["borg", "repo-info", "--info", "--json", "--log-json", "-r"] else: cmd = ["borg", "info", "--info", "--json", "--log-json"] cmd.append(profile.repo.url) diff --git a/src/vorta/borg/init.py b/src/vorta/borg/init.py index c752aab5..fc22cac2 100644 --- a/src/vorta/borg/init.py +++ b/src/vorta/borg/init.py @@ -33,7 +33,7 @@ def prepare(cls, params): if borg_compat.check('V2'): cmd = [ "borg", - "rcreate", + "repo-create", "--info", "--log-json", f"--encryption={params['encryption']}", diff --git a/src/vorta/borg/list_repo.py b/src/vorta/borg/list_repo.py index 664778d6..0093a4be 100644 --- a/src/vorta/borg/list_repo.py +++ b/src/vorta/borg/list_repo.py @@ -25,7 +25,7 @@ def prepare(cls, profile): ret['ok'] = False # Set back to false, so we can do our own checks here. if borg_compat.check('V2'): - cmd = ['borg', 'rlist', '--info', '--log-json', '--json', '-r'] + cmd = ['borg', 'repo-list', '--info', '--log-json', '--json', '-r'] else: cmd = ['borg', 'list', '--info', '--log-json', '--json'] cmd.append(f'{profile.repo.url}')