From d6c563e881889841f0cf061debae7c818e7d5629 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Mon, 21 May 2018 19:52:29 +0200 Subject: [PATCH] If a comic doesn't have library and id info, then try to update the info in all the libraries. --- .../controllers/v2/synccontroller_v2.cpp | 53 +++++++++++++------ 1 file changed, 37 insertions(+), 16 deletions(-) diff --git a/YACReaderLibrary/server/controllers/v2/synccontroller_v2.cpp b/YACReaderLibrary/server/controllers/v2/synccontroller_v2.cpp index 1f38a785..09602ea9 100644 --- a/YACReaderLibrary/server/controllers/v2/synccontroller_v2.cpp +++ b/YACReaderLibrary/server/controllers/v2/synccontroller_v2.cpp @@ -31,24 +31,45 @@ void SyncControllerV2::service(HttpRequest &request, HttpResponse &response) if(comicInfoProgress.length() == 4 || comicInfoProgress.length() == 5) { - libraryId = comicInfoProgress.at(0).toULongLong(); - comicId = comicInfoProgress.at(1).toULongLong(); - hash = comicInfoProgress.at(2); - currentPage = comicInfoProgress.at(3).toInt(); - - ComicInfo info; - info.currentPage = currentPage; - info.hash = hash; //TODO remove the hash check and add UUIDs for libraries - info.id = comicId; - - //Client 2.1+ version - if(comicInfoProgress.length() > 4) + if (comicInfoProgress.at(0) == "unknown") { - currentRating = comicInfoProgress.at(4).toInt(); - info.rating = currentRating; - } + libraryId = comicInfoProgress.at(0).toULongLong(); + comicId = comicInfoProgress.at(1).toULongLong(); + hash = comicInfoProgress.at(2); + currentPage = comicInfoProgress.at(3).toInt(); - DBHelper::updateFromRemoteClient(libraryId,info); + ComicInfo info; + info.currentPage = currentPage; + info.hash = hash; //TODO remove the hash check and add UUIDs for libraries + info.id = comicId; + + //Client 2.1+ version + if(comicInfoProgress.length() > 4) + { + currentRating = comicInfoProgress.at(4).toInt(); + info.rating = currentRating; + } + + DBHelper::updateFromRemoteClient(libraryId,info); + } + else + { + hash = comicInfoProgress.at(2); + currentPage = comicInfoProgress.at(3).toInt(); + + ComicInfo info; + info.currentPage = currentPage; + info.hash = hash; //TODO remove the hash check and add UUIDs for libraries + + //Client 2.1+ version + if(comicInfoProgress.length() > 4) + { + currentRating = comicInfoProgress.at(4).toInt(); + info.rating = currentRating; + } + + DBHelper::updateFromRemoteClientWithHash(info); + } } } }