mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-23 16:26:29 +00:00
repository: cleanup(): close segment before unlinking
On Windows, trying to delete a file that is already open raises an exception. Docs: https://docs.python.org/3/library/os.html#os.remove
This commit is contained in:
parent
62341673c1
commit
2a8cacf517
1 changed files with 2 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue