[entropy*] before calling Client.backup_repository() or Client.restore_repository(), make sure that transactions are committed
This commit is contained in:
@@ -40,6 +40,8 @@ def _backup_client_repository(entropy_client):
|
||||
if not os.path.isfile(dbpath):
|
||||
return True
|
||||
|
||||
# make sure to commit any transaction before backing-up
|
||||
entropy_client.installed_repository().commit()
|
||||
backed_up, msg = entropy_client.backup_repository(dbpath)
|
||||
return backed_up
|
||||
|
||||
@@ -186,6 +188,8 @@ def _database_restore(entropy_client):
|
||||
continue
|
||||
break
|
||||
|
||||
# make sure to commit any transaction before restoring
|
||||
entropy_client.installed_repository().commit()
|
||||
status, err_msg = entropy_client.restore_repository(dbpath,
|
||||
etpConst['etpdatabaseclientfilepath'])
|
||||
if status:
|
||||
|
||||
@@ -590,6 +590,8 @@ def repositories(options):
|
||||
elif cmd == "backup":
|
||||
|
||||
db_path = Entropy._get_local_database_file()
|
||||
# make sure to close all repos before backing-up
|
||||
Entropy.close_repositories()
|
||||
rc, err_msg = Entropy.backup_repository(db_path,
|
||||
backup_dir = os.path.dirname(db_path))
|
||||
if not rc:
|
||||
@@ -640,6 +642,8 @@ def repositories(options):
|
||||
continue
|
||||
break
|
||||
|
||||
# make sure to close all repos before restoring
|
||||
Entropy.close_repositories()
|
||||
status, err_msg = Entropy.restore_repository(dbpath, db_file)
|
||||
if status:
|
||||
return 0
|
||||
|
||||
@@ -52,9 +52,12 @@ class SulfurApplicationEventsMixin:
|
||||
|
||||
def on_dbBackupButton_clicked(self, widget):
|
||||
self.start_working()
|
||||
status, err_msg = self._entropy.backup_repository(
|
||||
etpConst['etpdatabaseclientfilepath'])
|
||||
self.end_working()
|
||||
with self._privileges:
|
||||
# make sure to commit any transaction before backing-up
|
||||
self._entropy.installed_repository().commit()
|
||||
status, err_msg = self._entropy.backup_repository(
|
||||
etpConst['etpdatabaseclientfilepath'])
|
||||
self.end_working()
|
||||
if not status:
|
||||
okDialog( self.ui.main, "%s: %s" % (_("Error during backup"),
|
||||
err_msg,) )
|
||||
@@ -71,6 +74,8 @@ class SulfurApplicationEventsMixin:
|
||||
|
||||
self.start_working()
|
||||
with self._privileges:
|
||||
# make sure to commit any transaction before restoring
|
||||
self._entropy.installed_repository().commit()
|
||||
status, err_msg = self._entropy.restore_repository(dbpath,
|
||||
etpConst['etpdatabaseclientfilepath'])
|
||||
self.end_working()
|
||||
|
||||
Reference in New Issue
Block a user