PropagateDirectory: Set initial dir mtime to server mtime #7119

It's still not synced in any way later.
This commit is contained in:
Christian Kamm 2019-03-29 10:16:09 +01:00 committed by Kevin Ottens
parent 69887c531e
commit cd10e3d28c
No known key found for this signature in database
GPG key ID: 074BBBCB8DECC9E2
2 changed files with 22 additions and 0 deletions

View file

@ -965,6 +965,12 @@ void PropagateDirectory::slotSubJobsFinished(SyncFileItem::Status status)
propagator()->_journal->deleteFileRecord(_item->_originalFile, true);
}
if (_item->_instruction == CSYNC_INSTRUCTION_NEW && _item->_direction == SyncFileItem::Down) {
// special case for local MKDIR, set local directory mtime
// (it's not synced later at all, but can be nice to have it set initially)
FileSystem::setModTime(propagator()->getFilePath(_item->destination()), _item->_modtime);
}
// For new directories we always want to update the etag once
// the directory has been propagated. Otherwise the directory
// could appear locally without being added to the database.

View file

@ -698,6 +698,22 @@ private slots:
QCOMPARE(QFileInfo(fakeFolder.localPath() + conflictName).permissions(), perm);
}
#endif
// Check that server mtime is set on directories on initial propagation
void testDirectoryInitialMtime()
{
FakeFolder fakeFolder{ FileInfo{} };
fakeFolder.remoteModifier().mkdir("foo");
fakeFolder.remoteModifier().insert("foo/bar");
auto datetime = QDateTime::currentDateTime();
datetime.setSecsSinceEpoch(datetime.toSecsSinceEpoch()); // wipe ms
fakeFolder.remoteModifier().find("foo")->lastModified = datetime;
QVERIFY(fakeFolder.syncOnce());
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
QCOMPARE(QFileInfo(fakeFolder.localPath() + "foo").lastModified(), datetime);
}
};
QTEST_GUILESS_MAIN(TestSyncEngine)