def restore_done(x, tarfilename, outputlocation, callback): dhnio.Dprint(8, "restore_monitor.restore_done " + str(x)) global _WorkingBackupIDs global _WorkingRestoreProgress global OnRestoreDoneFunc backupID, result = x.split(" ") if result == "done": p = backup_tar.extracttar(tarfilename, outputlocation) if p: d = threads.deferToThread(p.wait) d.addBoth(extract_done, backupID, tarfilename, callback) return result = "extract failed" _WorkingBackupIDs.pop(backupID, None) _WorkingRestoreProgress.pop(backupID, None) tmpfile.throw_out(tarfilename, "restore " + result) if OnRestoreDoneFunc is not None: OnRestoreDoneFunc(backupID, result) if callback: callback(backupID, result)
def extract_done(retcode, backupID, tarfilename, callback): dhnio.Dprint(8, "restore_monitor.extract_done %s result: %s" % (backupID, str(retcode))) global OnRestoreDoneFunc _WorkingBackupIDs.pop(backupID, None) _WorkingRestoreProgress.pop(backupID, None) tmpfile.throw_out(tarfilename, "file extracted") if OnRestoreDoneFunc is not None: OnRestoreDoneFunc(backupID, "restore done") if callback: callback(backupID, "restore done")
def restore_failed(x, tarfilename, callback): dhnio.Dprint(8, "restore_monitor.restore_failed " + str(x)) global _WorkingBackupIDs global _WorkingRestoreProgress global OnRestoreDoneFunc if isinstance(x, Exception) or isinstance(x, str): backupID, result = str(x).split(" ") _WorkingBackupIDs.pop(backupID, None) _WorkingRestoreProgress.pop(backupID, None) tmpfile.throw_out(tarfilename, "restore " + result) if OnRestoreDoneFunc is not None: OnRestoreDoneFunc(backupID, result) if callback: callback(backupID, result)
def doRemoveTempFile(self, arg): tmpfile.throw_out(arg[1], 'block restored')