1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-25 17:27:31 +00:00

kill filter process in case of borg exceptions, fixes #6401

in the finally-block, we wait for the filter process to die. but it only dies
voluntarily if all data was processed by the filter and it terminates due to EOF.

otoh, if borg has thrown an early exception, e.g. "archive already exists",
we need to kill the filter process to bring it to an early end. in that
case, we also do not need to check the filter rc, because we know we killed it.
This commit is contained in:
Thomas Waldmann 2022-03-04 23:32:12 +01:00 committed by aspargas2
parent 2bcee08b88
commit 83deedb13a

View file

@ -329,6 +329,14 @@ def create_filter_process(cmd, stream, stream_close, inbound=True):
try: try:
yield stream yield stream
except Exception:
# something went wrong with processing the stream by borg
logger.debug('Exception, killing the filter...')
proc.kill()
borg_succeeded = False
raise
else:
borg_succeeded = True
finally: finally:
if stream_close: if stream_close:
stream.close() stream.close()
@ -339,5 +347,6 @@ def create_filter_process(cmd, stream, stream_close, inbound=True):
logger.debug('filter cmd exited with code %d', rc) logger.debug('filter cmd exited with code %d', rc)
if filter_stream_close: if filter_stream_close:
filter_stream.close() filter_stream.close()
if rc: if borg_succeeded and rc:
# if borg did not succeed, we know that we killed the filter process
raise Error('filter %s failed, rc=%d' % (cmd, rc)) raise Error('filter %s failed, rc=%d' % (cmd, rc))