aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/jobs/syncjob.cpp6
-rw-r--r--lib/syncdata.cpp20
2 files changed, 16 insertions, 10 deletions
diff --git a/lib/jobs/syncjob.cpp b/lib/jobs/syncjob.cpp
index 9b1b46f0..f5c632bf 100644
--- a/lib/jobs/syncjob.cpp
+++ b/lib/jobs/syncjob.cpp
@@ -37,10 +37,12 @@ SyncJob::SyncJob(const QString& since, const Filter& filter, int timeout,
BaseJob::Status SyncJob::prepareResult()
{
d.parseJson(jsonData());
- if (d.unresolvedRooms().isEmpty())
+ if (Q_LIKELY(d.unresolvedRooms().isEmpty()))
return Success;
- qCCritical(MAIN).noquote() << "Incomplete sync response, missing rooms:"
+ Q_ASSERT(d.unresolvedRooms().isEmpty());
+ qCCritical(MAIN).noquote() << "Rooms missing after processing sync "
+ "response, possibly a bug in SyncData: "
<< d.unresolvedRooms().join(',');
return IncorrectResponse;
}
diff --git a/lib/syncdata.cpp b/lib/syncdata.cpp
index 396e77eb..b0cd8e4d 100644
--- a/lib/syncdata.cpp
+++ b/lib/syncdata.cpp
@@ -185,14 +185,18 @@ void SyncData::parseJson(const QJsonObject& json, const QString& baseDir)
// We have a Qt container on the right and an STL one on the left
roomData.reserve(roomData.size() + static_cast<size_t>(rs.size()));
for (auto roomIt = rs.begin(); roomIt != rs.end(); ++roomIt) {
- auto roomJson =
- roomIt->isObject()
- ? roomIt->toObject()
- : loadJson(baseDir + fileNameForRoom(roomIt.key()));
- if (roomJson.isEmpty()) {
- unresolvedRoomIds.push_back(roomIt.key());
- continue;
- }
+ QJsonObject roomJson;
+ if (!baseDir.isEmpty()) {
+ // Loading data from the local cache, with room objects saved in
+ // individual files rather than inline
+ roomJson = loadJson(baseDir + fileNameForRoom(roomIt.key()));
+ if (roomJson.isEmpty()) {
+ unresolvedRoomIds.push_back(roomIt.key());
+ continue;
+ }
+ } else // When loading from /sync response, everything is inline
+ roomJson = roomIt->toObject();
+
roomData.emplace_back(roomIt.key(), joinState, roomJson);
const auto& r = roomData.back();
totalEvents += r.state.size() + r.ephemeral.size()