ソースを参照

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
Olivier Goffart 7 年 前
コミット
73d933115a
2 ファイル変更6 行追加0 行削除
  1. 1 0
      src/libsync/propagatedownload.cpp
  2. 5 0
      test/testsyncvirtualfiles.cpp

+ 1 - 0
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;
     }

+ 5 - 0
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());