backups: terminate Extract_Worker on error in main process
This commit is contained in:
parent
d86865d299
commit
29bd92aad9
@ -714,8 +714,8 @@ class Extract_Worker(Process):
|
|||||||
self.print_callback("Moving to dir "+self.base_dir)
|
self.print_callback("Moving to dir "+self.base_dir)
|
||||||
os.chdir(self.base_dir)
|
os.chdir(self.base_dir)
|
||||||
|
|
||||||
for filename in iter(self.queue.get,None):
|
for filename in iter(self.queue.get, None):
|
||||||
if filename == "FINISHED":
|
if filename == "FINISHED" or filename == "ERROR":
|
||||||
break
|
break
|
||||||
|
|
||||||
if BACKUP_DEBUG:
|
if BACKUP_DEBUG:
|
||||||
@ -793,7 +793,11 @@ class Extract_Worker(Process):
|
|||||||
self.print_callback("Removing file "+filename)
|
self.print_callback("Removing file "+filename)
|
||||||
os.remove(filename)
|
os.remove(filename)
|
||||||
|
|
||||||
|
os.unlink(self.restore_pipe)
|
||||||
|
|
||||||
if self.tar2_process != None:
|
if self.tar2_process != None:
|
||||||
|
if filename == "ERROR":
|
||||||
|
self.tar2_process.terminate()
|
||||||
if self.tar2_process.wait() != 0:
|
if self.tar2_process.wait() != 0:
|
||||||
raise QubesException(
|
raise QubesException(
|
||||||
"ERROR: unable to extract files for {0}.".\
|
"ERROR: unable to extract files for {0}.".\
|
||||||
@ -802,7 +806,6 @@ class Extract_Worker(Process):
|
|||||||
# Finished extracting the tar file
|
# Finished extracting the tar file
|
||||||
self.tar2_process = None
|
self.tar2_process = None
|
||||||
|
|
||||||
os.unlink(self.restore_pipe)
|
|
||||||
if BACKUP_DEBUG:
|
if BACKUP_DEBUG:
|
||||||
self.print_callback("Finished extracting thread")
|
self.print_callback("Finished extracting thread")
|
||||||
|
|
||||||
@ -877,8 +880,8 @@ def restore_vm_dirs (backup_source, restore_tmpdir, passphrase, vms_dirs, vms,
|
|||||||
else:
|
else:
|
||||||
filelist_pipe = command.stdout
|
filelist_pipe = command.stdout
|
||||||
|
|
||||||
|
try:
|
||||||
while True:
|
while True:
|
||||||
|
|
||||||
filename = filelist_pipe.readline().strip(" \t\r\n")
|
filename = filelist_pipe.readline().strip(" \t\r\n")
|
||||||
|
|
||||||
if BACKUP_DEBUG:
|
if BACKUP_DEBUG:
|
||||||
@ -890,6 +893,9 @@ def restore_vm_dirs (backup_source, restore_tmpdir, passphrase, vms_dirs, vms,
|
|||||||
hmacfile = filelist_pipe.readline().strip(" \t\r\n")
|
hmacfile = filelist_pipe.readline().strip(" \t\r\n")
|
||||||
if BACKUP_DEBUG:
|
if BACKUP_DEBUG:
|
||||||
print_callback("Getting hmac:"+hmacfile)
|
print_callback("Getting hmac:"+hmacfile)
|
||||||
|
if not hmacfile or hmacfile=="EOF":
|
||||||
|
# Premature end of archive, either of tar1_command or vmproc exited with error
|
||||||
|
break
|
||||||
|
|
||||||
if not any(map(lambda x: filename.startswith(x), vms_dirs)):
|
if not any(map(lambda x: filename.startswith(x), vms_dirs)):
|
||||||
if BACKUP_DEBUG:
|
if BACKUP_DEBUG:
|
||||||
@ -914,7 +920,15 @@ def restore_vm_dirs (backup_source, restore_tmpdir, passphrase, vms_dirs, vms,
|
|||||||
"because of a VM error: {1}".format(
|
"because of a VM error: {1}".format(
|
||||||
backup_source, vmproc.stderr.read()))
|
backup_source, vmproc.stderr.read()))
|
||||||
|
|
||||||
|
if filename and filename!="EOF":
|
||||||
|
raise QubesException("Premature end of archive, the last file was %s" % filename)
|
||||||
|
except:
|
||||||
|
to_extract.put("ERROR")
|
||||||
|
extract_proc.join()
|
||||||
|
raise
|
||||||
|
else:
|
||||||
to_extract.put("FINISHED")
|
to_extract.put("FINISHED")
|
||||||
|
|
||||||
if BACKUP_DEBUG:
|
if BACKUP_DEBUG:
|
||||||
print_callback("Waiting for the extraction process to finish...")
|
print_callback("Waiting for the extraction process to finish...")
|
||||||
extract_proc.join()
|
extract_proc.join()
|
||||||
|
Loading…
Reference in New Issue
Block a user