From: Olivier Goffart Date: Sat, 18 Aug 2018 07:14:01 +0000 (+0200) Subject: Virtual Files: Set the mtime of the virtual file to that of the server X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~21^2~468^2~522 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=73d933115aa60b75557d39e0c892baf1e7c752d7;p=nextcloud-desktop.git Virtual Files: Set the mtime of the virtual file to that of the server Note: When the server mtime is modified, the mtime of the file is not updated Issue #6727 --- diff --git a/src/libsync/propagatedownload.cpp b/src/libsync/propagatedownload.cpp index 85e9d3867..8eca4ff67 100644 --- a/src/libsync/propagatedownload.cpp +++ b/src/libsync/propagatedownload.cpp @@ -402,6 +402,7 @@ void PropagateDownloadFile::startAfterIsEncryptedIsChecked() file.open(QFile::ReadWrite | QFile::Truncate); file.write(" "); file.close(); + FileSystem::setModTime(fn, _item->_modtime); updateMetadata(false); return; } diff --git a/test/testsyncvirtualfiles.cpp b/test/testsyncvirtualfiles.cpp index 415c90220..dff186ab7 100644 --- a/test/testsyncvirtualfiles.cpp +++ b/test/testsyncvirtualfiles.cpp @@ -68,9 +68,12 @@ private slots: // Create a virtual file for a new remote file fakeFolder.remoteModifier().mkdir("A"); fakeFolder.remoteModifier().insert("A/a1", 64); + auto someDate = QDateTime(QDate(1984, 07, 30), QTime(1,3,2)); + fakeFolder.remoteModifier().setModTime("A/a1", someDate); QVERIFY(fakeFolder.syncOnce()); QVERIFY(!fakeFolder.currentLocalState().find("A/a1")); QVERIFY(fakeFolder.currentLocalState().find("A/a1.owncloud")); + QCOMPARE(QFileInfo(fakeFolder.localPath() + "A/a1.owncloud").lastModified(), someDate); QVERIFY(fakeFolder.currentRemoteState().find("A/a1")); QVERIFY(itemInstruction(completeSpy, "A/a1.owncloud", CSYNC_INSTRUCTION_NEW)); QCOMPARE(dbRecord(fakeFolder, "A/a1.owncloud")._type, ItemTypeVirtualFile); @@ -80,6 +83,7 @@ private slots: QVERIFY(fakeFolder.syncOnce()); QVERIFY(!fakeFolder.currentLocalState().find("A/a1")); QVERIFY(fakeFolder.currentLocalState().find("A/a1.owncloud")); + QCOMPARE(QFileInfo(fakeFolder.localPath() + "A/a1.owncloud").lastModified(), someDate); QVERIFY(fakeFolder.currentRemoteState().find("A/a1")); QCOMPARE(dbRecord(fakeFolder, "A/a1.owncloud")._type, ItemTypeVirtualFile); QVERIFY(completeSpy.isEmpty()); @@ -90,6 +94,7 @@ private slots: QVERIFY(fakeFolder.syncOnce()); QVERIFY(!fakeFolder.currentLocalState().find("A/a1")); QVERIFY(fakeFolder.currentLocalState().find("A/a1.owncloud")); + QCOMPARE(QFileInfo(fakeFolder.localPath() + "A/a1.owncloud").lastModified(), someDate); QVERIFY(fakeFolder.currentRemoteState().find("A/a1")); QCOMPARE(dbRecord(fakeFolder, "A/a1.owncloud")._type, ItemTypeVirtualFile); QVERIFY(completeSpy.isEmpty());