From 71f8dd3a17f88e8dbb82294fd79ab13bf432bfd0 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sun, 12 Feb 2023 21:25:44 +0100 Subject: [PATCH] FilesystemObjectProcessors.process_pipe: also add same exception handler there --- src/borg/archive.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/borg/archive.py b/src/borg/archive.py index 839dc0710..0cd81e784 100644 --- a/src/borg/archive.py +++ b/src/borg/archive.py @@ -1433,11 +1433,20 @@ def process_pipe(self, *, path, cache, fd, mode, user=None, group=None): item.uid = uid if gid is not None: item.gid = gid - self.process_file_chunks(item, cache, self.stats, self.show_progress, backup_io_iter(self.chunker.chunkify(fd))) - item.get_size(memorize=True) - self.stats.nfiles += 1 - self.add_item(item, stats=self.stats) - return status + try: + self.process_file_chunks( + item, cache, self.stats, self.show_progress, backup_io_iter(self.chunker.chunkify(fd)) + ) + except BackupOSError: + # see comments in process_file's exception handler, same issue here. + for chunk in item.get("chunks", []): + cache.chunk_decref(chunk.id, self.stats, wait=False) + raise + else: + item.get_size(memorize=True) + self.stats.nfiles += 1 + self.add_item(item, stats=self.stats) + return status def process_file(self, *, path, parent_fd, name, st, cache, flags=flags_normal): with self.create_helper(path, st, None) as (item, status, hardlinked, hl_chunks): # no status yet