From bc9651b664619506ccaf37c4b850156b82c2eaf0 Mon Sep 17 00:00:00 2001
From: spfenwick <101789313+spfenwick@users.noreply.github.com>
Date: Wed, 29 Apr 2026 12:29:05 +1200
Subject: [PATCH] fix: use same file name as KOReader for OPDS downloads
(#1286)
This allows KOSync to work for files downloaded from OPDS when set to
use filename matching
## Summary
* **What is the goal of this PR?** Brings the names of files downloaded
via OPDS into line with the KOReader OPDS plugin so the files sync when
KOSync is set to filename matching
* **What changes are included?** Change the filename generated by the
OPDS browser from "\
- \" to "\ - \"
so it matches KOReader.
## Additional Context
* Add any other information that might be helpful for the reviewer
(e.g., performance implications, potential risks,
specific areas to focus on).
Both KOReader and crosspoint sanitise the filename by removing special
characters. This step seems to already use the same rules.
---
### AI Usage
While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.
Did you use AI tools to help write this code? NO
---
src/activities/browser/OpdsBookBrowserActivity.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/activities/browser/OpdsBookBrowserActivity.cpp b/src/activities/browser/OpdsBookBrowserActivity.cpp
index 3fe2fa865..96e4e28c0 100644
--- a/src/activities/browser/OpdsBookBrowserActivity.cpp
+++ b/src/activities/browser/OpdsBookBrowserActivity.cpp
@@ -264,7 +264,7 @@ void OpdsBookBrowserActivity::downloadBook(const OpdsEntry& book) {
const std::string feedUrl = UrlUtils::buildUrl(server.url, currentPath);
std::string downloadUrl = UrlUtils::buildUrl(feedUrl, book.href);
std::string filename =
- "/" + StringUtils::sanitizeFilename(book.title + (book.author.empty() ? "" : " - " + book.author)) + ".epub";
+ "/" + StringUtils::sanitizeFilename((book.author.empty() ? "" : book.author + " - ") + book.title) + ".epub";
LOG_DBG("OPDS", "Downloading: %s -> %s", downloadUrl.c_str(), filename.c_str());
const auto result = HttpDownloader::downloadToFile(