1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-02-08 15:37:09 +00:00

files cache: update ctime, mtime of known and "unchanged" files, fixes #4915

This commit is contained in:
Thomas Waldmann 2024-09-20 00:38:18 +02:00
parent a891559578
commit c100e7b1f5
No known key found for this signature in database
GPG key ID: 243ACFA951F78E01

View file

@ -553,21 +553,23 @@ def file_known_and_unchanged(self, hashed_path, path_hash, st):
if "i" in cache_mode and entry.inode != st.st_ino: if "i" in cache_mode and entry.inode != st.st_ino:
files_cache_logger.debug("KNOWN-CHANGED: file inode number has changed: %r", hashed_path) files_cache_logger.debug("KNOWN-CHANGED: file inode number has changed: %r", hashed_path)
return True, None return True, None
if "c" in cache_mode and timestamp_to_int(entry.ctime) != st.st_ctime_ns: ctime = int_to_timestamp(safe_ns(st.st_ctime_ns))
if "c" in cache_mode and entry.ctime != ctime:
files_cache_logger.debug("KNOWN-CHANGED: file ctime has changed: %r", hashed_path) files_cache_logger.debug("KNOWN-CHANGED: file ctime has changed: %r", hashed_path)
return True, None return True, None
if "m" in cache_mode and timestamp_to_int(entry.mtime) != st.st_mtime_ns: mtime = int_to_timestamp(safe_ns(st.st_mtime_ns))
if "m" in cache_mode and entry.mtime != mtime:
files_cache_logger.debug("KNOWN-CHANGED: file mtime has changed: %r", hashed_path) files_cache_logger.debug("KNOWN-CHANGED: file mtime has changed: %r", hashed_path)
return True, None return True, None
# we ignored the inode number in the comparison above or it is still same. # V = any of the inode number, mtime, ctime values.
# we ignored V in the comparison above or it is still the same value.
# if it is still the same, replacing it in the tuple doesn't change it. # if it is still the same, replacing it in the tuple doesn't change it.
# if we ignored it, a reason for doing that is that files were moved to a new # if we ignored it, a reason for doing that is that files were moved/copied to
# disk / new fs (so a one-time change of inode number is expected) and we wanted # a new disk / new fs (so a one-time change of V is expected) and we wanted
# to avoid everything getting chunked again. to be able to re-enable the inode # to avoid everything getting chunked again. to be able to re-enable the
# number comparison in a future backup run (and avoid chunking everything # V comparison in a future backup run (and avoid chunking everything again at
# again at that time), we need to update the inode number in the cache with what # that time), we need to update V in the cache with what we see in the filesystem.
# we see in the filesystem. self.files[path_hash] = msgpack.packb(entry._replace(inode=st.st_ino, ctime=ctime, mtime=mtime, age=0))
self.files[path_hash] = msgpack.packb(entry._replace(inode=st.st_ino, age=0))
chunks = [ChunkListEntry(*chunk) for chunk in entry.chunks] # convert to list of namedtuple chunks = [ChunkListEntry(*chunk) for chunk in entry.chunks] # convert to list of namedtuple
return True, chunks return True, chunks