fix unintended file cache eviction, fixes #1430

thanks much to e477 for diagnosing this and finding the right fix.
This commit is contained in:
Thomas Waldmann 2016-08-04 00:06:15 +02:00
parent e5a3229fd2
commit b96bc155ac
1 changed files with 6 additions and 3 deletions

View File

@ -196,10 +196,13 @@ Chunk index: {0.total_unique_chunks:20d} {0.total_chunks:20d}"""
ttl = int(os.environ.get('BORG_FILES_CACHE_TTL', 20))
with open(os.path.join(self.path, 'files'), 'wb') as fd:
for path_hash, item in self.files.items():
# Discard cached files with the newest mtime to avoid
# issues with filesystem snapshots and mtime precision
# Only keep files seen in this backup that are older than newest mtime seen in this backup -
# this is to avoid issues with filesystem snapshots and mtime granularity.
# Also keep files from older backups that have not reached BORG_FILES_CACHE_TTL yet.
item = msgpack.unpackb(item)
if item[0] < ttl and bigint_to_int(item[3]) < self._newest_mtime:
age = item[0]
if age == 0 and bigint_to_int(item[3]) < self._newest_mtime or \
age > 0 and age < ttl:
msgpack.pack((path_hash, item), fd)
self.config.set('cache', 'manifest', hexlify(self.manifest.id).decode('ascii'))
self.config.set('cache', 'timestamp', self.manifest.timestamp)