mirror of
https://github.com/borgbackup/borg.git
synced 2026-06-13 19:00:44 -04:00
creating a new segment: use "xb" mode, fixes #2099
"ab" seems to make no sense here (if there is already a (crap, but non-empty) segment file, we would write a MAGIC right into the middle of the resulting file) and cause #2099.
This commit is contained in:
parent
ca0c1dab11
commit
6996fa6dc0
1 changed files with 2 additions and 1 deletions
|
|
@ -670,7 +670,8 @@ class LoggedIO:
|
|||
if not os.path.exists(dirname):
|
||||
os.mkdir(dirname)
|
||||
sync_dir(os.path.join(self.path, 'data'))
|
||||
self._write_fd = open(self.segment_filename(self.segment), 'ab')
|
||||
# play safe: fail if file exists (do not overwrite existing contents, do not append)
|
||||
self._write_fd = open(self.segment_filename(self.segment), 'xb')
|
||||
self._write_fd.write(MAGIC)
|
||||
self.offset = MAGIC_LEN
|
||||
return self._write_fd
|
||||
|
|
|
|||
Loading…
Reference in a new issue