mirror of https://github.com/borgbackup/borg.git
slightly refactor write_commit using new "want_new" flag
This commit is contained in:
parent
1f387d911a
commit
3715d2da3e
|
@ -1482,14 +1482,11 @@ class LoggedIO:
|
||||||
return self.segment, self.put_header_fmt.size
|
return self.segment, self.put_header_fmt.size
|
||||||
|
|
||||||
def write_commit(self, intermediate=False):
|
def write_commit(self, intermediate=False):
|
||||||
|
# Intermediate commits go directly into the current segment - this makes checking their validity more
|
||||||
|
# expensive, but is faster and reduces clobber. Final commits go into a new segment.
|
||||||
|
fd = self.get_write_fd(want_new=not intermediate)
|
||||||
if intermediate:
|
if intermediate:
|
||||||
# Intermediate commits go directly into the current segment - this makes checking their validity more
|
|
||||||
# expensive, but is faster and reduces clobber.
|
|
||||||
fd = self.get_write_fd()
|
|
||||||
fd.sync()
|
fd.sync()
|
||||||
else:
|
|
||||||
self.close_segment()
|
|
||||||
fd = self.get_write_fd()
|
|
||||||
header = self.header_no_crc_fmt.pack(self.header_fmt.size, TAG_COMMIT)
|
header = self.header_no_crc_fmt.pack(self.header_fmt.size, TAG_COMMIT)
|
||||||
crc = self.crc_fmt.pack(crc32(header) & 0xffffffff)
|
crc = self.crc_fmt.pack(crc32(header) & 0xffffffff)
|
||||||
fd.write(b''.join((crc, header)))
|
fd.write(b''.join((crc, header)))
|
||||||
|
|
Loading…
Reference in New Issue