mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-27 02:08:54 +00:00
Merge pull request #1844 from enkore/issue/1815
check: catch two kinds of different repos
This commit is contained in:
commit
9b1241eecd
3 changed files with 13 additions and 0 deletions
|
@ -833,6 +833,9 @@ def check(self, repository, repair=False, archive=None, last=None, prefix=None,
|
|||
self.repair = repair
|
||||
self.repository = repository
|
||||
self.init_chunks()
|
||||
if not self.chunks:
|
||||
logger.error('Repository contains no apparent data at all, cannot continue check/repair.')
|
||||
return False
|
||||
self.key = self.identify_key(repository)
|
||||
if Manifest.MANIFEST_ID not in self.chunks:
|
||||
logger.error("Repository manifest not found!")
|
||||
|
|
|
@ -438,6 +438,9 @@ def report_error(msg):
|
|||
transaction_id = self.get_index_transaction_id()
|
||||
if transaction_id is None:
|
||||
transaction_id = self.io.get_latest_segment()
|
||||
if transaction_id is None:
|
||||
report_error('This repository contains no valid data.')
|
||||
return False
|
||||
if repair:
|
||||
self.io.cleanup(transaction_id)
|
||||
segments_transaction_id = self.io.get_segments_transaction_id()
|
||||
|
|
|
@ -1444,6 +1444,13 @@ def test_extra_chunks(self):
|
|||
self.cmd('check', self.repository_location, exit_code=0)
|
||||
self.cmd('extract', '--dry-run', self.repository_location + '::archive1', exit_code=0)
|
||||
|
||||
def test_empty_repository(self):
|
||||
with Repository(self.repository_location, exclusive=True) as repository:
|
||||
for id_ in repository.list():
|
||||
repository.delete(id_)
|
||||
repository.commit()
|
||||
self.cmd('check', self.repository_location, exit_code=1)
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.platform == 'cygwin', reason='remote is broken on cygwin and hangs')
|
||||
class RemoteArchiverTestCase(ArchiverTestCase):
|
||||
|
|
Loading…
Reference in a new issue