[server] Also remove tmpdir in case of error during restore database command
authorDenis Laxalde <denis.laxalde@logilab.fr>
Thu, 23 Feb 2017 17:51:11 +0100
changeset 11982 8d1525c76e65
parent 11981 56e99b59272f
child 11983 5de78b6fff2e
[server] Also remove tmpdir in case of error during restore database command
cubicweb/server/migractions.py
--- a/cubicweb/server/migractions.py	Thu Feb 23 17:47:18 2017 +0100
+++ b/cubicweb/server/migractions.py	Thu Feb 23 17:51:11 2017 +0100
@@ -276,7 +276,8 @@
             print('-> error trying to restore %s [%s]' % (source.uri, exc))
             if not self.confirm('Continue anyway?', default='n'):
                 raise SystemExit(1)
-        shutil.rmtree(tmpdir)
+        finally:
+            shutil.rmtree(tmpdir)
         # call hooks
         repo.bootstrap()
         repo.hm.call_hooks('server_restore', repo=repo, timestamp=backupfile)