Merge pull request #49 from jpirnay/fix-kosync-empty
fix: Show remote KOSync progress again
This commit is contained in:
@@ -226,9 +226,7 @@ void KOReaderSyncActivity::performSync() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Defer remote EPUB mapping until user chooses Apply. Upload only needs the
|
||||
// precomputed local XPath, so this avoids post-fetch inflate churn and keeps
|
||||
// the GET session reusable for PUT.
|
||||
// Prepare remote mapping state for the next step.
|
||||
hasRemoteProgress = false;
|
||||
remotePositionMapped = false;
|
||||
remotePosition.spineIndex = -1;
|
||||
@@ -266,6 +264,18 @@ void KOReaderSyncActivity::performSync() {
|
||||
|
||||
// Compare intent keeps the legacy chooser flow (apply vs upload), which is
|
||||
// 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.
|
||||
releaseEpubForMapping();
|
||||
|
||||
@@ -442,15 +452,13 @@ void KOReaderSyncActivity::render(RenderLock&&) {
|
||||
|
||||
// Remote progress - chapter and page
|
||||
renderer.drawText(UI_10_FONT_ID, contentRect.x + 20, 160, tr(STR_REMOTE_LABEL), true);
|
||||
if (hasRemoteProgress) {
|
||||
char remoteChapterStr[128];
|
||||
snprintf(remoteChapterStr, sizeof(remoteChapterStr), " %s", remoteChapter.c_str());
|
||||
renderer.drawText(UI_10_FONT_ID, contentRect.x + 20, 185, remoteChapterStr);
|
||||
char remotePageStr[64];
|
||||
snprintf(remotePageStr, sizeof(remotePageStr), tr(STR_PAGE_OVERALL_FORMAT), remotePosition.pageNumber + 1,
|
||||
remoteProgress.percentage * 100);
|
||||
renderer.drawText(UI_10_FONT_ID, contentRect.x + 20, 210, remotePageStr);
|
||||
}
|
||||
char remoteChapterStr[128];
|
||||
snprintf(remoteChapterStr, sizeof(remoteChapterStr), " %s", remoteChapter.c_str());
|
||||
renderer.drawText(UI_10_FONT_ID, contentRect.x + 20, 185, remoteChapterStr);
|
||||
char remotePageStr[64];
|
||||
snprintf(remotePageStr, sizeof(remotePageStr), tr(STR_PAGE_OVERALL_FORMAT), remotePosition.pageNumber + 1,
|
||||
remoteProgress.percentage * 100);
|
||||
renderer.drawText(UI_10_FONT_ID, contentRect.x + 20, 210, remotePageStr);
|
||||
|
||||
if (!remoteProgress.device.empty()) {
|
||||
char deviceStr[64];
|
||||
@@ -547,14 +555,17 @@ bool KOReaderSyncActivity::ensureEpubLoadedForMapping() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool KOReaderSyncActivity::ensureRemotePositionMapped() {
|
||||
bool KOReaderSyncActivity::ensureRemotePositionMapped(const bool closeSessionBeforeMapping) {
|
||||
if (remotePositionMapped) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Apply needs remote->local mapping, which triggers EPUB inflate work.
|
||||
// Release HTTP/TLS session first so mapping has maximum heap headroom.
|
||||
KOReaderSyncClient::endPersistentSession();
|
||||
// Mapping remote->local can trigger EPUB inflate work. For apply/pull paths,
|
||||
// release HTTP/TLS first to maximize heap headroom. Compare pre-map keeps
|
||||
// the warmed session alive so Upload can reuse it without a fresh handshake.
|
||||
if (closeSessionBeforeMapping) {
|
||||
KOReaderSyncClient::endPersistentSession();
|
||||
}
|
||||
|
||||
{
|
||||
RenderLock lock(*this);
|
||||
|
||||
@@ -115,5 +115,5 @@ class KOReaderSyncActivity final : public Activity {
|
||||
void releaseEpubForMapping();
|
||||
bool computeLocalProgressAndChapter();
|
||||
void computeRemoteChapter();
|
||||
bool ensureRemotePositionMapped();
|
||||
bool ensureRemotePositionMapped(bool closeSessionBeforeMapping = true);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user