From 019dde09e1ef80dbc48b928c6f05547547f9965d Mon Sep 17 00:00:00 2001 From: jpirnay Date: Wed, 8 Apr 2026 14:54:26 +0200 Subject: [PATCH] Deal with empty responses --- lib/KOReaderSync/KOReaderSyncClient.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/KOReaderSync/KOReaderSyncClient.cpp b/lib/KOReaderSync/KOReaderSyncClient.cpp index 7253416f..e0cd2eeb 100644 --- a/lib/KOReaderSync/KOReaderSyncClient.cpp +++ b/lib/KOReaderSync/KOReaderSyncClient.cpp @@ -441,6 +441,14 @@ KOReaderSyncClient::Error KOReaderSyncClient::getProgress(const std::string& doc return JSON_ERROR; } + // kosync convention: no stored progress for the document is signalled by + // HTTP 200 with an empty body ("{}"), not by 404. Detect that here so the + // caller doesn't apply a zeroed-out position as if it were real progress. + if (doc["document"].isNull() || doc["progress"].isNull()) { + LOG_DBG("KOSync", "Empty progress payload — treating as not found"); + return NOT_FOUND; + } + outProgress.document = documentHash; outProgress.progress = doc["progress"].as(); outProgress.percentage = doc["percentage"].as();