backups: improve errors handling

Report nice error message (not a traceback), interrupt the process on
non-recoverable error (when extraction process is already dead).
This commit is contained in:
Marek Marczykowski-Górecki 2014-09-17 14:31:20 +02:00
parent f0bbb28398
commit 228ae07543
2 changed files with 21 additions and 3 deletions

View File

@ -742,7 +742,13 @@ def wait_backup_feedback(progress_callback, in_stream, streamproc,
if len(buffer) <= 0:
return ""
backup_target.write(buffer)
try:
backup_target.write(buffer)
except IOError as e:
if e.errno == errno.EPIPE:
run_error = "target"
else:
raise
if hmac:
hmac.stdin.write(buffer)
@ -1145,6 +1151,15 @@ def restore_vm_dirs (backup_source, restore_tmpdir, passphrase, vms_dirs, vms,
while True:
if running_backup_operation and running_backup_operation.canceled:
break
if not extract_proc.is_alive():
command.terminate()
command.wait()
expect_tar_error = True
if vmproc:
vmproc.terminate()
vmproc.wait()
vmproc = None
break
if nextfile is not None:
filename = nextfile
else:

View File

@ -227,8 +227,11 @@ def main():
exit (0)
backup_restore_do(restore_info,
host_collection=host_collection)
try:
backup_restore_do(restore_info,
host_collection=host_collection)
except QubesException as e:
print >> sys.stderr, "ERROR: %s" % str(e)
host_collection.unlock_db()