mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-24 16:55:36 +00:00
recover_segment(): don't assume we have an fd for segment
Suggested by @ThomasWaldmann. Avoiding a complex assumption should make the code easier to understand and maintain. (Technically we do have an fd for the segment, because the only caller opens the segment and checks it before calling for repair.)
This commit is contained in:
parent
d83b919d52
commit
04887439a0
1 changed files with 3 additions and 1 deletions
|
@ -515,7 +515,9 @@ def iter_objects(self, segment, include_data=False):
|
|||
header = fd.read(self.header_fmt.size)
|
||||
|
||||
def recover_segment(self, segment, filename):
|
||||
self.fds.pop(segment).close()
|
||||
fd = self.fds.pop(segment)
|
||||
if fd is not None:
|
||||
fd.close()
|
||||
# FIXME: save a copy of the original file
|
||||
with open(filename, 'rb') as fd:
|
||||
data = memoryview(fd.read())
|
||||
|
|
Loading…
Reference in a new issue