Repository navigation
fix: handle Borg 2 repo-info and info output without cache stats or encryption mode - #2633
Merged
Merged
Conversation
…ncryption mode Borg 2 reports `cache` without `stats`, archive `stats` without `deduplicated_size`, and from 2.0.0b22 `encryption` as a cipher name instead of a mode. BorgInfoRepoJob and BorgInfoArchiveJob raised KeyError on this, so adding an existing Borg 2 repo failed and left an orphan repo row, and archive refresh never completed. Skip missing stats, keep the archive size recorded at create time, and map the Borg 2 encryption info to a Borg 1 style mode (`repokey-<cipher>`, `keyfile-<cipher>` or `none`). Add fixtures based on real 2.0.0b25 output. Fixes #2613
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
BorgInfoRepoJob.process_result(Add Existing Repository) andBorgInfoArchiveJob.process_result(archive Refresh) read keys that Borg 2 does not emit and raisedKeyError:cacheis{"path": ...}(or{}) with nostats.encryptionis{"encryption": <cipher>, "id_hash": ...}, plus"keyfile": <path>when the key is stored as a keyfile, instead of{"mode": ...}.statshas nodeduplicated_sizefor an existing archive.With Borg 2, adding an existing repo failed with "Unable to add your repository." and left a repo row behind, so a retry reported the repo as already added. Archive refresh never succeeded.
Changes:
cache.statsis present. Without it the repo sizes stay empty and the repo tab shows "N/A", as it already does.deduplicated_size.encryption_mode()helper ininfo_repo.pyreturns the value stored inRepoModel.encryption:modeas before when Borg reports it (Borg 1 and Borg 2 up to b21);nonefor the plaintext ciphersnone,none-sha256andnone-blake3(b22–b24);repokey-<cipher>orkeyfile-<cipher>, for examplerepokey-chacha20-poly1305.Why a synthesised mode instead of the bare cipher name the issue suggests:
RepoModel.encryptionis compared with'none'inborg_job.py,change_passphrase.py,init.pyandinfo_repo.py, and "Change passphrase" is only offered when it starts withrepokey(repo_tab.py). A barechacha20-poly1305would disable Change passphrase for every b22+ repo. Keeping the Borg 1 shape needs no change in those readers.Things to be aware of:
repokey-chacha20-poly1305for both sha256 and blake3 repos.repokey-authenticated-sha256/-blake3, so Change passphrase is offered for them. With Borg 1 it is not (authenticatedfails therepokeycheck). Borg 2.0.0b25 acceptedkey change-passphraseon such a repo.repo-create --encryptionvalues,init.pyshould store the same form, or created and added repos will differ.Related Issue
Fixes #2613
Motivation and Context
See above. Not included, as the issue says: the missing
Nonecheck afterArchiveModel.get_or_none(...)ininfo_archive.py, and the repo-create encryption choices for b22+.How Has This Been Tested?
On macOS. Unit tests run with Borg 1.4.3 (nox default) and a mocked
Popen.repo_info_v2_*andinfo_v2_*are realborg repo-info --jsonandborg info --jsonoutput from Borg 2.0.0b25, with paths, host and user replaced by placeholders and the archive id and duration set to match the test data.tests/unit/test_repo.py::test_info_repo_process_result: seven shapes (Borg 1, Borg 2 withmode, b25 repokey, b25 keyfile,none-sha256,none, Borg 1none), checking the stored mode, sizes and whether the passphrase is written to the keyring.tests/unit/test_repo.py::test_repo_add_existing_borg2: the Add Existing Repository dialog end to end with the b25 fixture.tests/unit/test_archives.py::test_refresh_archive_info_borg2: Refresh keeps the archive size and updates the duration.KeyErrors above; the Borg 1 cases pass.test_keyring_darwin.py::test_keyring_non_ascii_repo, which writes to the real login keychain).repokey-chacha20-poly1305,keyfile-aes256-ocb,repokey-authenticated-sha256andrepokey-authenticated-blake3, sizes stayed empty, archive sizes were kept and nothing raised.Not tested:
modeup to b21, the plaintext ciphers at b22–b24) come from reading the Borg source.Types of changes
Checklist:
I provide my contribution under the terms of the license of this repository and I affirm the Developer Certificate of Origin.