mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-24 08:45:13 +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):
|
def cleanup(self, transaction_id):
|
||||||
"""Delete segment files left by aborted transactions"""
|
"""Delete segment files left by aborted transactions"""
|
||||||
|
self.close_segment()
|
||||||
self.segment = transaction_id + 1
|
self.segment = transaction_id + 1
|
||||||
count = 0
|
count = 0
|
||||||
for segment, filename in self.segment_iterator(reverse=True):
|
for segment, filename in self.segment_iterator(reverse=True):
|
||||||
if segment > transaction_id:
|
if segment > transaction_id:
|
||||||
if segment in self.fds:
|
self.delete_segment(segment)
|
||||||
del self.fds[segment]
|
|
||||||
safe_unlink(filename)
|
|
||||||
count += 1
|
count += 1
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in a new issue