mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-26 01:37:20 +00:00
repo cleanup/write: invalidate cached FDs
This commit is contained in:
parent
4a4c8884ee
commit
7122913825
1 changed files with 8 additions and 0 deletions
|
@ -1176,6 +1176,8 @@ def cleanup(self, transaction_id):
|
||||||
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:
|
||||||
|
del self.fds[segment]
|
||||||
truncate_and_unlink(filename)
|
truncate_and_unlink(filename)
|
||||||
count += 1
|
count += 1
|
||||||
else:
|
else:
|
||||||
|
@ -1232,6 +1234,12 @@ def get_write_fd(self, no_new=False, raise_full=False):
|
||||||
self._write_fd = SyncFile(self.segment_filename(self.segment), binary=True)
|
self._write_fd = SyncFile(self.segment_filename(self.segment), binary=True)
|
||||||
self._write_fd.write(MAGIC)
|
self._write_fd.write(MAGIC)
|
||||||
self.offset = MAGIC_LEN
|
self.offset = MAGIC_LEN
|
||||||
|
if self.segment in self.fds:
|
||||||
|
# we may have a cached fd for a segment file we already deleted and
|
||||||
|
# we are writing now a new segment file to same file name. get rid of
|
||||||
|
# of the cached fd that still refers to the old file, so it will later
|
||||||
|
# get repopulated (on demand) with a fd that refers to the new file.
|
||||||
|
del self.fds[self.segment]
|
||||||
return self._write_fd
|
return self._write_fd
|
||||||
|
|
||||||
def get_fd(self, segment):
|
def get_fd(self, segment):
|
||||||
|
|
Loading…
Reference in a new issue