diff --git a/src/cryfs/filesystem/fsblobstore/DirBlob.cpp b/src/cryfs/filesystem/fsblobstore/DirBlob.cpp index bd24e173..d6481a10 100644 --- a/src/cryfs/filesystem/fsblobstore/DirBlob.cpp +++ b/src/cryfs/filesystem/fsblobstore/DirBlob.cpp @@ -160,8 +160,9 @@ void DirBlob::statChildWithSizeAlreadySet(const Key &key, struct ::stat *result) void DirBlob::updateAccessTimestampForChild(const Key &key, TimestampUpdateBehavior timestampUpdateBehavior) { std::unique_lock lock(_mutex); - _entries.updateAccessTimestampForChild(key, timestampUpdateBehavior); - _changed = true; + if (_entries.updateAccessTimestampForChild(key, timestampUpdateBehavior)) { + _changed = true; + } } void DirBlob::updateModificationTimestampForChild(const Key &key) { diff --git a/src/cryfs/filesystem/fsblobstore/utils/DirEntryList.cpp b/src/cryfs/filesystem/fsblobstore/utils/DirEntryList.cpp index ab40c938..51f2401a 100644 --- a/src/cryfs/filesystem/fsblobstore/utils/DirEntryList.cpp +++ b/src/cryfs/filesystem/fsblobstore/utils/DirEntryList.cpp @@ -228,7 +228,7 @@ void DirEntryList::setAccessTimes(const blockstore::Key &key, timespec lastAcces found->setLastModificationTime(lastModificationTime); } -void DirEntryList::updateAccessTimestampForChild(const blockstore::Key &key, TimestampUpdateBehavior timestampUpdateBehavior) { +bool DirEntryList::updateAccessTimestampForChild(const blockstore::Key &key, TimestampUpdateBehavior timestampUpdateBehavior) { ASSERT(timestampUpdateBehavior == TimestampUpdateBehavior::RELATIME, "Currently only relatime supported"); auto found = _findByKey(key); const timespec lastAccessTime = found->lastAccessTime(); @@ -238,8 +238,12 @@ void DirEntryList::updateAccessTimestampForChild(const blockstore::Key &key, Tim .tv_sec = now.tv_sec - 60*60*24, .tv_nsec = now.tv_nsec }; - if (lastAccessTime < lastModificationTime || lastAccessTime < yesterday) - found->setLastAccessTime(now); + bool changed = false; + if (lastAccessTime < lastModificationTime || lastAccessTime < yesterday) { + found->setLastAccessTime(now); + changed = true; + } + return changed; } void DirEntryList::updateModificationTimestampForChild(const blockstore::Key &key) { diff --git a/src/cryfs/filesystem/fsblobstore/utils/DirEntryList.h b/src/cryfs/filesystem/fsblobstore/utils/DirEntryList.h index 9df2325b..a3973263 100644 --- a/src/cryfs/filesystem/fsblobstore/utils/DirEntryList.h +++ b/src/cryfs/filesystem/fsblobstore/utils/DirEntryList.h @@ -40,7 +40,7 @@ namespace cryfs { void setMode(const blockstore::Key &key, mode_t mode); bool setUidGid(const blockstore::Key &key, uid_t uid, gid_t gid); void setAccessTimes(const blockstore::Key &key, timespec lastAccessTime, timespec lastModificationTime); - void updateAccessTimestampForChild(const blockstore::Key &key, TimestampUpdateBehavior timestampUpdateBehavior); + bool updateAccessTimestampForChild(const blockstore::Key &key, TimestampUpdateBehavior timestampUpdateBehavior); void updateModificationTimestampForChild(const blockstore::Key &key); private: