mirror of
https://github.com/borgbackup/borg.git
synced 2025-03-13 07:33:47 +00:00
Avoid filesystem snapshot related race condition with mtimes
This commit is contained in:
parent
4ddbf0d02a
commit
9d508c9d18
1 changed files with 6 additions and 1 deletions
|
@ -60,6 +60,7 @@ class Cache(object):
|
|||
|
||||
def _read_files(self):
|
||||
self.files = {}
|
||||
self._newest_mtime = 0
|
||||
with open(os.path.join(self.path, 'files'), 'rb') as fd:
|
||||
u = msgpack.Unpacker()
|
||||
while True:
|
||||
|
@ -90,6 +91,9 @@ class Cache(object):
|
|||
if self.files is not None:
|
||||
with open(os.path.join(self.path, 'files'), 'wb') as fd:
|
||||
for item in self.files.iteritems():
|
||||
# Discard cached files with the newest mtime to avoid
|
||||
# issues with filesystem snapshots and mtime precision
|
||||
if item[1][3] < self._newest_mtime:
|
||||
msgpack.pack(item, fd)
|
||||
self.config.set('cache', 'manifest', self.manifest.id.encode('hex'))
|
||||
with open(os.path.join(self.path, 'config'), 'w') as fd:
|
||||
|
@ -206,4 +210,5 @@ class Cache(object):
|
|||
def memorize_file(self, path_hash, st, ids):
|
||||
# Entry: Age, inode, size, mtime, chunk ids
|
||||
self.files[path_hash] = 0, st.st_ino, st.st_size, st.st_mtime, ids
|
||||
self._newest_mtime = max(self._newest_mtime, st.st_mtime)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue