Skip to content

Commit

Permalink
PropagateDirectory: Set initial dir mtime to server mtime #7119
Browse files Browse the repository at this point in the history
It's still not synced in any way later.
  • Loading branch information
ckamm committed Apr 9, 2019
1 parent 31c699b commit f7d4b29
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/libsync/owncloudpropagator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,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.
Expand Down
16 changes: 16 additions & 0 deletions test/testsyncengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f7d4b29

Please sign in to comment.