devtools/__init__.py
changeset 10063 335fa90d5ef4
parent 10038 f2f065d406dc
child 10064 91a8f355c082
--- 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