repo delete: add destroy to allowed rpc methods, fixes issue #114

also: add test, automate YES confirmation for testing
This commit is contained in:
Thomas Waldmann 2015-07-26 17:38:16 +02:00
parent fde952a6d9
commit 195545075a
3 changed files with 18 additions and 5 deletions

View File

@ -288,11 +288,13 @@ Type "Yes I am sure" if you understand this and want to continue.\n""")
print("You requested to completely DELETE the repository *including* all archives it contains:")
for archive_info in manifest.list_archive_infos(sort_by='ts'):
print(format_archive(archive_info))
print("""Type "YES" if you understand this and want to continue.\n""")
if input('Do you want to continue? ') == 'YES':
repository.destroy()
cache.destroy()
print("Repository and corresponding cache were deleted.")
while not os.environ.get('BORG_CHECK_I_KNOW_WHAT_I_AM_DOING'):
print("""Type "YES" if you understand this and want to continue.\n""")
if input('Do you want to continue? ') == 'YES':
break
repository.destroy()
cache.destroy()
print("Repository and corresponding cache were deleted.")
return self.exit_code
def do_mount(self, args):

View File

@ -34,6 +34,7 @@ class RepositoryServer:
'check',
'commit',
'delete',
'destroy',
'get',
'list',
'negotiate',

View File

@ -394,6 +394,16 @@ class ArchiverTestCase(ArchiverTestCaseBase):
repository = Repository(self.repository_path)
self.assert_equal(len(repository), 1)
def test_delete_repo(self):
self.create_regular_file('file1', size=1024 * 80)
self.create_regular_file('dir2/file2', size=1024 * 80)
self.cmd('init', self.repository_location)
self.cmd('create', self.repository_location + '::test', 'input')
self.cmd('create', self.repository_location + '::test.2', 'input')
self.cmd('delete', self.repository_location)
# Make sure the repo is gone
self.assertFalse(os.path.exists(self.repository_path))
def test_corrupted_repository(self):
self.cmd('init', self.repository_location)
self.create_src_archive('test')