mirror of
https://github.com/borgbackup/borg.git
synced 2025-02-23 06:31:58 +00:00
try to work around Windows idiocy of open files
apparently, we may be able to rewrite an open file if we rename it first. i have no way to test this, unfortunately
This commit is contained in:
parent
e59f1d50d9
commit
8c48015e70
1 changed files with 5 additions and 1 deletions
|
@ -91,10 +91,14 @@ def header_replace(filename, old_magic, new_magic, inplace=True):
|
|||
# works because our old file handle is still open
|
||||
# so even though the file is removed, we can still
|
||||
# read it until the file is closed.
|
||||
os.unlink(filename)
|
||||
os.rename(filename, filename + '.tmp')
|
||||
with open(filename, 'wb') as new_segment:
|
||||
new_segment.write(new_magic)
|
||||
new_segment.write(segment.read())
|
||||
# the little dance with the .tmp file is necessary
|
||||
# because Windows won't allow overwriting an open
|
||||
# file.
|
||||
os.unlink(filename + '.tmp')
|
||||
|
||||
def find_attic_keyfile(self):
|
||||
"""find the attic keyfiles
|
||||
|
|
Loading…
Reference in a new issue