refactor: unify book cache clearing for epub, txt, and xtc files (#1875)

This commit is contained in:
WuTofu
2026-05-21 14:44:10 +03:00
committed by GitHub
parent dc404b41c7
commit 2dd491b62e
9 changed files with 77 additions and 32 deletions
@@ -1,6 +1,5 @@
#include "OpdsBookBrowserActivity.h"
#include <Epub.h>
#include <GfxRenderer.h>
#include <I18n.h>
#include <Logging.h>
@@ -14,6 +13,7 @@
#include "components/UITheme.h"
#include "fontIds.h"
#include "network/HttpDownloader.h"
#include "util/BookCacheUtils.h"
#include "util/StringUtils.h"
#include "util/UrlUtils.h"
@@ -283,7 +283,7 @@ void OpdsBookBrowserActivity::downloadBook(const OpdsEntry& book) {
nullptr, server.username, server.password);
if (result == HttpDownloader::OK) {
Epub(filename, "/.crosspoint").clearCache();
clearBookCache(filename);
state = BrowserState::BROWSING;
} else {
state = BrowserState::ERROR;
@@ -8,6 +8,7 @@
#include "MappedInputManager.h"
#include "components/UITheme.h"
#include "fontIds.h"
#include "util/BookCacheUtils.h"
void ClearCacheActivity::onEnter() {
Activity::onEnter();
@@ -94,8 +95,8 @@ void ClearCacheActivity::clearCache() {
file.getName(name, sizeof(name));
String itemName(name);
// Only delete directories starting with epub_ or xtc_
if (file.isDirectory() && (itemName.startsWith("epub_") || itemName.startsWith("xtc_"))) {
// Only delete directories matching known book cache names.
if (file.isDirectory() && isBookCacheDirectoryName(itemName.c_str())) {
String fullPath = "/.crosspoint/" + itemName;
LOG_DBG("CLEAR_CACHE", "Removing cache: %s", fullPath.c_str());