MCPcopy
hub / github.com/borgbackup/borg / load

Method load

src/borg/crypto/key.py:679–701  ·  view source on GitHub ↗
(self, target, passphrase)

Source from the content-addressed store, hash-verified

677 return str(path)
678
679 def load(self, target, passphrase):
680 if self.STORAGE == KeyBlobStorage.KEYFILE:
681 with open(target) as fd:
682 key_data = "".join(fd.readlines()[1:])
683 elif self.STORAGE == KeyBlobStorage.REPO:
684 # While the repository is encrypted, we consider a repokey repository with a blank
685 # passphrase an unencrypted repository.
686 self.logically_encrypted = passphrase != "" # nosec B105
687
688 # what we get in target is just a repo location, but we already have the repo obj:
689 target = self.repository
690 key_data = target.load_key()
691 if not key_data:
692 # if we got an empty key, it means there is no key.
693 loc = target._location.canonical_path()
694 raise RepoKeyNotFoundError(loc) from None
695 key_data = key_data.decode("utf-8") # remote repo: msgpack issue #99, getting bytes
696 else:
697 raise TypeError("Unsupported borg key storage type")
698 success = self._load(key_data, passphrase)
699 if success:
700 self.target = target
701 return success
702
703 def save(self, target, passphrase, algorithm, create=False):
704 key_data = self._save(passphrase, algorithm)

Callers 15

detectMethod · 0.45
loadMethod · 0.45
do_deleteMethod · 0.45
do_repo_deleteMethod · 0.45
do_undeleteMethod · 0.45
wrapperFunction · 0.45
do_debug_format_objMethod · 0.45
manifestMethod · 0.45
test_key_export_repokeyFunction · 0.45
test_renameFunction · 0.45
test_migrate_lock_aliveFunction · 0.45
open_archiveFunction · 0.45

Calls 4

_loadMethod · 0.95
load_keyMethod · 0.45
canonical_pathMethod · 0.45

Tested by 14

manifestMethod · 0.36
test_key_export_repokeyFunction · 0.36
test_renameFunction · 0.36
test_migrate_lock_aliveFunction · 0.36
test_debug_dump_manifestFunction · 0.36
test_debug_dump_archiveFunction · 0.36
check_compressionFunction · 0.36
test_transfer_upgradeFunction · 0.36
test_create_dry_runFunction · 0.36
test_spoofed_manifestFunction · 0.36