[devtools][pg] Remove a wrong assertion in _backup_database
authorChristophe de Vienne <christophe@unlish.com>
Mon, 06 Oct 2014 12:08:41 +0200
changeset 10063 335fa90d5ef4
parent 10062 c5637b5337e8
child 10064 91a8f355c082
[devtools][pg] Remove a wrong assertion in _backup_database When using pre_setup_database, a repo gets initialised before calling backup_database. Hence self._repo is NOT None it that case.
devtools/__init__.py
--- a/devtools/__init__.py	Wed Nov 26 16:24:28 2014 +0100
+++ b/devtools/__init__.py	Mon Oct 06 12:08:41 2014 +0200
@@ -674,12 +674,14 @@
             backup_name = self._backup_name(db_id)
             self._drop(backup_name)
             self.system_source['db-name'] = backup_name
-            # during postgres database initialization, there is no repo set here.
-            assert self._repo is None
-            #self._repo.turn_repo_off()
-            createdb(self.helper, self.system_source, self.dbcnx, self.cursor, template=orig_name)
-            self.dbcnx.commit()
-            #self._repo.turn_repo_on()
+            if self._repo:
+                self._repo.turn_repo_off()
+            try:
+                createdb(self.helper, self.system_source, self.dbcnx, self.cursor, template=orig_name)
+                self.dbcnx.commit()
+            finally:
+                if self._repo:
+                    self._repo.turn_repo_on()
             return backup_name
         finally:
             self.system_source['db-name'] = orig_name