mirror of
https://github.com/borgbackup/borg.git
synced 2025-02-20 21:27:32 +00:00
fix determination of newest mtime, fixes #1860
bug: if no files were added/modified, _newest_mtime stayed at its initial 0 value. when saving the files cache, this killed all age 0 entries. Now using None as initial value, so we can spot that circumstance. The 2 ** 63 - 1 value is just so it is MAX_INT on a 64bit platform, for better performance. It can be easily increased when y2262 is coming.
This commit is contained in:
parent
ea6515d1aa
commit
cabcbc5887
1 changed files with 5 additions and 2 deletions
|
@ -191,7 +191,7 @@ def close(self):
|
|||
|
||||
def _read_files(self):
|
||||
self.files = {}
|
||||
self._newest_mtime = 0
|
||||
self._newest_mtime = None
|
||||
logger.debug('Reading files cache ...')
|
||||
with open(os.path.join(self.path, 'files'), 'rb') as fd:
|
||||
u = msgpack.Unpacker(use_list=True)
|
||||
|
@ -222,6 +222,9 @@ def commit(self):
|
|||
if not self.txn_active:
|
||||
return
|
||||
if self.files is not None:
|
||||
if self._newest_mtime is None:
|
||||
# was never set because no files were modified/added
|
||||
self._newest_mtime = 2 ** 63 - 1 # nanoseconds, good until y2262
|
||||
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():
|
||||
|
@ -451,4 +454,4 @@ def memorize_file(self, path_hash, st, ids):
|
|||
# Entry: Age, inode, size, mtime, chunk ids
|
||||
mtime_ns = st.st_mtime_ns
|
||||
self.files[path_hash] = msgpack.packb((0, st.st_ino, st.st_size, int_to_bigint(mtime_ns), ids))
|
||||
self._newest_mtime = max(self._newest_mtime, mtime_ns)
|
||||
self._newest_mtime = max(self._newest_mtime or 0, mtime_ns)
|
||||
|
|
Loading…
Reference in a new issue