Merge pull request #2100 from ThomasWaldmann/fix-double-magic

creating a new segment: use "xb" mode, fixes #2099
This commit is contained in:
TW 2017-01-28 14:17:57 +01:00 committed by GitHub
commit 528891aee9
1 changed files with 2 additions and 1 deletions

View File

@ -670,7 +670,8 @@ class LoggedIO:
if not os.path.exists(dirname): if not os.path.exists(dirname):
os.mkdir(dirname) os.mkdir(dirname)
sync_dir(os.path.join(self.path, 'data')) 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._write_fd.write(MAGIC)
self.offset = MAGIC_LEN self.offset = MAGIC_LEN
return self._write_fd return self._write_fd