Bläddra i källkod

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

also: add test, automate YES confirmation for testing
Thomas Waldmann 10 år sedan
förälder
incheckning
195545075a
3 ändrade filer med 18 tillägg och 5 borttagningar
  1. 7 5
      borg/archiver.py
  2. 1 0
      borg/remote.py
  3. 10 0
      borg/testsuite/archiver.py

+ 7 - 5
borg/archiver.py

@@ -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):

+ 1 - 0
borg/remote.py

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

+ 10 - 0
borg/testsuite/archiver.py

@@ -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')