mirror of
https://github.com/theupdateframework/python-tuf
synced 2026-05-24 10:08:28 +00:00
Merge pull request #1173 from jku/add-missing-local-repository-error
Add MissingLocalRepositoryError
This commit is contained in:
commit
b57aa5857b
3 changed files with 13 additions and 0 deletions
|
|
@ -224,6 +224,9 @@ def test_1__init__exceptions(self):
|
|||
# directory.
|
||||
tuf.settings.repositories_directory = self.client_directory
|
||||
|
||||
# Test: repository does not exist
|
||||
self.assertRaises(tuf.exceptions.MissingLocalRepositoryError, updater.Updater,
|
||||
'test_non_existing_repository', self.repository_mirrors)
|
||||
|
||||
# Test: empty client repository (i.e., no metadata directory).
|
||||
metadata_backup = self.client_metadata + '.backup'
|
||||
|
|
|
|||
|
|
@ -727,6 +727,12 @@ def __init__(self, repository_name, repository_mirrors):
|
|||
# Set the path for the current set of metadata files.
|
||||
repositories_directory = tuf.settings.repositories_directory
|
||||
repository_directory = os.path.join(repositories_directory, self.repository_name)
|
||||
|
||||
# raise MissingLocalRepository if the repo does not exist at all.
|
||||
if not os.path.exists(repository_directory):
|
||||
raise tuf.exceptions.MissingLocalRepositoryError('Local repository ' +
|
||||
repr(repository_directory) + ' does not exist.')
|
||||
|
||||
current_path = os.path.join(repository_directory, 'metadata', 'current')
|
||||
|
||||
# Ensure the current path is valid/exists before saving it.
|
||||
|
|
|
|||
|
|
@ -115,6 +115,10 @@ class RepositoryError(Error):
|
|||
"""Indicate an error with a repository's state, such as a missing file."""
|
||||
|
||||
|
||||
class MissingLocalRepositoryError(RepositoryError):
|
||||
"""Raised when a local repository could not be found."""
|
||||
|
||||
|
||||
class InsufficientKeysError(Error):
|
||||
"""Indicate that metadata role lacks a threshold of pubic or private keys."""
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue