Ensure file modification time is set if item modtime differs from journal modtime
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Mon, 10 Jul 2023 05:00:28 +0000 (13:00 +0800)
committerClaudio Cambra <claudio.cambra@nextcloud.com>
Mon, 7 Aug 2023 08:25:19 +0000 (16:25 +0800)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
src/libsync/syncengine.cpp

index 56af0770f628eeb5a4747370dd719cea3198c0ae..a999c8a0edbf59c9d210a747ca1cefe344686c64 100644 (file)
@@ -388,17 +388,17 @@ void OCC::SyncEngine::slotItemDiscovered(const OCC::SyncFileItemPtr &item)
             }
 
             // Update on-disk virtual file metadata
-            if (modificationHappened) {
-                if (item->_type == ItemTypeVirtualFile) {
-                    auto r = _syncOptions._vfs->updateMetadata(filePath, item->_modtime, item->_size, item->_fileId);
-                    if (!r) {
-                        item->_status = SyncFileItem::Status::NormalError;
-                        item->_instruction = CSYNC_INSTRUCTION_ERROR;
-                        item->_errorString = tr("Could not update virtual file metadata: %1").arg(r.error());
-                        emit itemCompleted(item, ErrorCategory::GenericError);
-                        return;
-                    }
-                } else if (!FileSystem::setModTime(filePath, item->_modtime)) {
+            if (modificationHappened && item->_type == ItemTypeVirtualFile) {
+                auto r = _syncOptions._vfs->updateMetadata(filePath, item->_modtime, item->_size, item->_fileId);
+                if (!r) {
+                    item->_status = SyncFileItem::Status::NormalError;
+                    item->_instruction = CSYNC_INSTRUCTION_ERROR;
+                    item->_errorString = tr("Could not update virtual file metadata: %1").arg(r.error());
+                    emit itemCompleted(item, ErrorCategory::GenericError);
+                    return;
+                }
+            } else if (modificationHappened || prev._modtime != item->_modtime) {
+                if (!FileSystem::setModTime(filePath, item->_modtime)) {
                     item->_instruction = CSYNC_INSTRUCTION_ERROR;
                     item->_errorString = tr("Could not update file metadata: %1").arg(filePath);
                     emit itemCompleted(item, ErrorCategory::GenericError);