Merge pull request #49 from jpirnay/fix-kosync-empty

fix: Show remote KOSync progress again
This commit is contained in:
jpirnay
2026-04-09 13:42:45 +02:00
committed by GitHub
2 changed files with 28 additions and 17 deletions
+27 -16
View File
@@ -226,9 +226,7 @@ void KOReaderSyncActivity::performSync() {
return; return;
} }
// Defer remote EPUB mapping until user chooses Apply. Upload only needs the // Prepare remote mapping state for the next step.
// precomputed local XPath, so this avoids post-fetch inflate churn and keeps
// the GET session reusable for PUT.
hasRemoteProgress = false; hasRemoteProgress = false;
remotePositionMapped = false; remotePositionMapped = false;
remotePosition.spineIndex = -1; remotePosition.spineIndex = -1;
@@ -266,6 +264,18 @@ void KOReaderSyncActivity::performSync() {
// Compare intent keeps the legacy chooser flow (apply vs upload), which is // Compare intent keeps the legacy chooser flow (apply vs upload), which is
// still useful for manual conflict decisions. // still useful for manual conflict decisions.
// Pre-map remote progress now so compare UI always shows concrete chapter/
// page data. The mapped result is cached and reused if Apply is chosen.
if (!ensureRemotePositionMapped(false)) {
{
RenderLock lock(*this);
state = SYNC_FAILED;
statusMessage = tr(STR_SYNC_FAILED_MSG);
}
requestUpdate(true);
return;
}
// Local progress was precomputed before network; keep using the cached value. // Local progress was precomputed before network; keep using the cached value.
releaseEpubForMapping(); releaseEpubForMapping();
@@ -442,15 +452,13 @@ void KOReaderSyncActivity::render(RenderLock&&) {
// Remote progress - chapter and page // Remote progress - chapter and page
renderer.drawText(UI_10_FONT_ID, contentRect.x + 20, 160, tr(STR_REMOTE_LABEL), true); renderer.drawText(UI_10_FONT_ID, contentRect.x + 20, 160, tr(STR_REMOTE_LABEL), true);
if (hasRemoteProgress) { char remoteChapterStr[128];
char remoteChapterStr[128]; snprintf(remoteChapterStr, sizeof(remoteChapterStr), " %s", remoteChapter.c_str());
snprintf(remoteChapterStr, sizeof(remoteChapterStr), " %s", remoteChapter.c_str()); renderer.drawText(UI_10_FONT_ID, contentRect.x + 20, 185, remoteChapterStr);
renderer.drawText(UI_10_FONT_ID, contentRect.x + 20, 185, remoteChapterStr); char remotePageStr[64];
char remotePageStr[64]; snprintf(remotePageStr, sizeof(remotePageStr), tr(STR_PAGE_OVERALL_FORMAT), remotePosition.pageNumber + 1,
snprintf(remotePageStr, sizeof(remotePageStr), tr(STR_PAGE_OVERALL_FORMAT), remotePosition.pageNumber + 1, remoteProgress.percentage * 100);
remoteProgress.percentage * 100); renderer.drawText(UI_10_FONT_ID, contentRect.x + 20, 210, remotePageStr);
renderer.drawText(UI_10_FONT_ID, contentRect.x + 20, 210, remotePageStr);
}
if (!remoteProgress.device.empty()) { if (!remoteProgress.device.empty()) {
char deviceStr[64]; char deviceStr[64];
@@ -547,14 +555,17 @@ bool KOReaderSyncActivity::ensureEpubLoadedForMapping() {
return true; return true;
} }
bool KOReaderSyncActivity::ensureRemotePositionMapped() { bool KOReaderSyncActivity::ensureRemotePositionMapped(const bool closeSessionBeforeMapping) {
if (remotePositionMapped) { if (remotePositionMapped) {
return true; return true;
} }
// Apply needs remote->local mapping, which triggers EPUB inflate work. // Mapping remote->local can trigger EPUB inflate work. For apply/pull paths,
// Release HTTP/TLS session first so mapping has maximum heap headroom. // release HTTP/TLS first to maximize heap headroom. Compare pre-map keeps
KOReaderSyncClient::endPersistentSession(); // the warmed session alive so Upload can reuse it without a fresh handshake.
if (closeSessionBeforeMapping) {
KOReaderSyncClient::endPersistentSession();
}
{ {
RenderLock lock(*this); RenderLock lock(*this);
+1 -1
View File
@@ -115,5 +115,5 @@ class KOReaderSyncActivity final : public Activity {
void releaseEpubForMapping(); void releaseEpubForMapping();
bool computeLocalProgressAndChapter(); bool computeLocalProgressAndChapter();
void computeRemoteChapter(); void computeRemoteChapter();
bool ensureRemotePositionMapped(); bool ensureRemotePositionMapped(bool closeSessionBeforeMapping = true);
}; };