Send optional document metadata with KOSync progress uploads

This commit is contained in:
jpirnay
2026-05-06 22:44:47 +02:00
parent bd71bf465c
commit dedc5bd4af
10 changed files with 78 additions and 7 deletions
@@ -405,6 +405,7 @@ void KOReaderSyncActivity::performUpload() {
progress.document = documentHash;
progress.progress = localProgress.xpath;
progress.percentage = localProgress.percentage;
progress.metadata = localDocumentMetadata;
const auto result = KOReaderSyncClient::updateProgress(progress);
KOReaderSyncClient::endPersistentSession();
@@ -717,6 +718,18 @@ bool KOReaderSyncActivity::computeLocalProgressAndChapter() {
localChapterLabel = (localTocIndex >= 0)
? epub->getTocItem(localTocIndex).title
: (std::string(tr(STR_SECTION_PREFIX)) + std::to_string(currentSpineIndex + 1));
if (KOREADER_STORE.getSendMetadata()) {
const size_t slash = epubPath.rfind('/');
KOReaderMetadata meta;
meta.filename = (slash != std::string::npos) ? epubPath.substr(slash + 1) : epubPath;
meta.title = epub->getTitle();
meta.authors = epub->getAuthor();
localDocumentMetadata = std::move(meta);
} else {
localDocumentMetadata.reset();
}
return true;
}
@@ -93,6 +93,7 @@ class KOReaderSyncActivity final : public Activity {
KOReaderPosition localProgress;
std::string remoteChapterLabel;
std::string localChapterLabel;
std::optional<KOReaderMetadata> localDocumentMetadata;
// Selection in result screen (0=Apply, 1=Upload)
int selectedOption = 0;