[server] Drop close/open steps in NativeSQLSource.restore()
authorDenis Laxalde <denis.laxalde@logilab.fr>
Thu, 23 Feb 2017 17:38:47 +0100
changeset 11979 c93b47ba0093
parent 11978 9d27e426adc2
child 11980 7c8aadc4b483
[server] Drop close/open steps in NativeSQLSource.restore() The only place where this is called is in ServerMigrationHelper.restore_database() where config.init_cnxset_pool is set to False. So these steps appear to be useless.
cubicweb/server/sources/native.py
--- a/cubicweb/server/sources/native.py	Tue Feb 07 10:37:37 2017 +0100
+++ b/cubicweb/server/sources/native.py	Thu Feb 23 17:38:47 2017 +0100
@@ -417,19 +417,13 @@
 
     def restore(self, backupfile, confirm, drop, format='native'):
         """method called to restore a backup of source's data"""
-        if self.repo.config.init_cnxset_pool:
-            self.close_source_connections()
-        try:
-            if format == 'portable':
-                helper = DatabaseIndependentBackupRestore(self)
-                helper.restore(backupfile)
-            elif format == 'native':
-                self.restore_from_file(backupfile, confirm, drop=drop)
-            else:
-                raise ValueError('Unknown format %r' % format)
-        finally:
-            if self.repo.config.init_cnxset_pool:
-                self.open_source_connections()
+        if format == 'portable':
+            helper = DatabaseIndependentBackupRestore(self)
+            helper.restore(backupfile)
+        elif format == 'native':
+            self.restore_from_file(backupfile, confirm, drop=drop)
+        else:
+            raise ValueError('Unknown format %r' % format)
 
     def init(self, activated, source_entity):
         super(NativeSQLSource, self).init(activated, source_entity)