diff --git a/src/borg/repository.py b/src/borg/repository.py index a8cb91d9c..247d9db1e 100644 --- a/src/borg/repository.py +++ b/src/borg/repository.py @@ -1448,13 +1448,12 @@ def get_segments_transaction_id(self): def cleanup(self, transaction_id): """Delete segment files left by aborted transactions""" + self.close_segment() self.segment = transaction_id + 1 count = 0 for segment, filename in self.segment_iterator(reverse=True): if segment > transaction_id: - if segment in self.fds: - del self.fds[segment] - safe_unlink(filename) + self.delete_segment(segment) count += 1 else: break