mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-25 09:19:31 +00:00
sync the containing directory also
This commit is contained in:
parent
fde5a60549
commit
99566a31c0
2 changed files with 14 additions and 0 deletions
|
@ -1,5 +1,16 @@
|
|||
import os
|
||||
import sys
|
||||
|
||||
|
||||
# POSIX-only, from borg 1.1 platform.base
|
||||
def sync_dir(path):
|
||||
fd = os.open(path, os.O_RDONLY)
|
||||
try:
|
||||
os.fsync(fd)
|
||||
finally:
|
||||
os.close(fd)
|
||||
|
||||
|
||||
if sys.platform.startswith('linux'): # pragma: linux only
|
||||
from .platform_linux import acl_get, acl_set, API_VERSION
|
||||
elif sys.platform.startswith('freebsd'): # pragma: freebsd only
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
from .hashindex import NSIndex
|
||||
from .locking import UpgradableLock, LockError, LockErrorT
|
||||
from .lrucache import LRUCache
|
||||
from .platform import sync_dir
|
||||
|
||||
MAX_OBJECT_SIZE = 20 * 1024 * 1024
|
||||
MAGIC = b'BORG_SEG'
|
||||
|
@ -600,6 +601,7 @@ def get_write_fd(self, no_new=False, raise_full=False):
|
|||
dirname = os.path.join(self.path, 'data', str(self.segment // self.segments_per_dir))
|
||||
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')
|
||||
self._write_fd.write(MAGIC)
|
||||
self.offset = MAGIC_LEN
|
||||
|
@ -744,4 +746,5 @@ def close_segment(self):
|
|||
# avoids spoiling the cache for the OS and other processes.
|
||||
os.posix_fadvise(self._write_fd.fileno(), 0, 0, os.POSIX_FADV_DONTNEED)
|
||||
self._write_fd.close()
|
||||
sync_dir(os.path.dirname(self._write_fd.name))
|
||||
self._write_fd = None
|
||||
|
|
Loading…
Reference in a new issue