From 33192e5e5dceaee1081ff7d0e65359cb8ba062b7 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Fri, 4 Mar 2022 22:39:22 +0100 Subject: [PATCH 1/2] import-tar: fix mtime type bug looks like with a .tar file created by the tar tool, tarinfo.mtime is a float [s]. So, after converting to nanoseconds, we need to cast to int because that's what Item.mtime wants. also added a safe_ns() there to clip values to the safe range. --- src/borg/archive.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/borg/archive.py b/src/borg/archive.py index 279a0e131..728c76bb1 100644 --- a/src/borg/archive.py +++ b/src/borg/archive.py @@ -1447,7 +1447,7 @@ class TarfileObjectProcessors: def create_helper(self, tarinfo, status=None, type=None): item = Item(path=make_path_safe(tarinfo.name), mode=tarinfo.mode | type, uid=tarinfo.uid, gid=tarinfo.gid, user=tarinfo.uname or None, group=tarinfo.gname or None, - mtime=tarinfo.mtime * 1000**3) + mtime=safe_ns(int(tarinfo.mtime * 1000**3))) yield item, status # if we get here, "with"-block worked ok without error/exception, the item was processed ok... self.add_item(item, stats=self.stats) From 7dc800fecdb6e72fe588010515e1be38dec7ef5a Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Fri, 4 Mar 2022 23:32:12 +0100 Subject: [PATCH 2/2] 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. --- src/borg/helpers/process.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/borg/helpers/process.py b/src/borg/helpers/process.py index bf87869f6..7af8d5fcb 100644 --- a/src/borg/helpers/process.py +++ b/src/borg/helpers/process.py @@ -329,6 +329,14 @@ def create_filter_process(cmd, stream, stream_close, inbound=True): try: 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: if 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) if 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))