Use db transactions when updating the progress from iOS

Timeouts were a problem before.
This commit is contained in:
Luis Ángel San Martín
2019-08-24 13:31:52 +02:00
parent 8bb43a7cf3
commit 9056fffb66
3 changed files with 132 additions and 4 deletions

View File

@ -27,6 +27,8 @@ void SyncControllerV2::service(HttpRequest &request, HttpResponse &response)
int currentRating;
unsigned long long lastTimeOpened;
QString hash;
QMap<qulonglong, QList<ComicInfo>> comics;
QList<ComicInfo> comicsWithNoLibrary;
foreach (QString comicInfo, data) {
QList<QString> comicInfoProgress = comicInfo.split("\t");
@ -47,8 +49,10 @@ void SyncControllerV2::service(HttpRequest &request, HttpResponse &response)
lastTimeOpened = comicInfoProgress.at(5).toULong();
info.lastTimeOpened = lastTimeOpened;
DBHelper::updateFromRemoteClient(libraryId, info);
if (!comics.contains(libraryId)) {
comics[libraryId] = QList<ComicInfo>();
}
comics[libraryId].push_back(info);
} else {
hash = comicInfoProgress.at(2);
currentPage = comicInfoProgress.at(3).toInt();
@ -63,10 +67,13 @@ void SyncControllerV2::service(HttpRequest &request, HttpResponse &response)
lastTimeOpened = comicInfoProgress.at(5).toULong();
info.lastTimeOpened = lastTimeOpened;
DBHelper::updateFromRemoteClientWithHash(info);
comicsWithNoLibrary.push_back(info);
}
}
}
DBHelper::updateFromRemoteClient(comics);
DBHelper::updateFromRemoteClientWithHash(comicsWithNoLibrary);
} else {
response.setStatus(412, "No comic info received");
response.write("", true);