Compare commits

..

1 Commits

Author SHA1 Message Date
Zando
8edb682e6e
Merge b483b46b40 into da4d3b5ea5 2026-01-29 23:00:15 +01:00
6 changed files with 21 additions and 19 deletions

@ -1 +1 @@
Subproject commit c39f253a7dabbc193a8d7d310fb8777dca0ab8f1 Subproject commit bd4e6707503ab9c97d13ee0d8f8c69e9ff03cd12

View File

@ -1,6 +1,7 @@
#include "CrossPointWebServer.h" #include "CrossPointWebServer.h"
#include <ArduinoJson.h> #include <ArduinoJson.h>
#include "util/BookCacheManager.h"
#include <Epub.h> #include <Epub.h>
#include <FsHelpers.h> #include <FsHelpers.h>
#include <SDCardManager.h> #include <SDCardManager.h>
@ -11,7 +12,6 @@
#include "html/FilesPageHtml.generated.h" #include "html/FilesPageHtml.generated.h"
#include "html/HomePageHtml.generated.h" #include "html/HomePageHtml.generated.h"
#include "util/BookCacheManager.h"
#include "util/StringUtils.h" #include "util/StringUtils.h"
namespace { namespace {
@ -875,6 +875,8 @@ void CrossPointWebServer::handleRename() const {
} }
} }
// WebSocket callback trampoline // WebSocket callback trampoline
void CrossPointWebServer::wsEventCallback(uint8_t num, WStype_t type, uint8_t* payload, size_t length) { void CrossPointWebServer::wsEventCallback(uint8_t num, WStype_t type, uint8_t* payload, size_t length) {
if (wsInstance) { if (wsInstance) {

View File

@ -80,4 +80,5 @@ class CrossPointWebServer {
void handleDelete() const; void handleDelete() const;
void handleMove() const; void handleMove() const;
void handleRename() const; void handleRename() const;
}; };

View File

@ -1,10 +1,8 @@
#include "BookCacheManager.h" #include "BookCacheManager.h"
#include <HardwareSerial.h>
#include "../CrossPointState.h"
#include "../RecentBooksStore.h"
#include "StringUtils.h" #include "StringUtils.h"
#include <HardwareSerial.h>
#include "../RecentBooksStore.h"
#include "../CrossPointState.h"
bool BookCacheManager::migrateCache(const String& oldPath, const String& newPath) { bool BookCacheManager::migrateCache(const String& oldPath, const String& newPath) {
if (oldPath == newPath) return true; if (oldPath == newPath) return true;
@ -54,7 +52,7 @@ bool BookCacheManager::migrateCache(const String& oldPath, const String& newPath
// It's a file. check if it's a supported book type // It's a file. check if it's a supported book type
if (!isSupportedFile(oldPath)) { if (!isSupportedFile(oldPath)) {
return true; // Not a book, nothing to migrate return true; // Not a book, nothing to migrate
} }
String oldCache = getCachePath(oldPath); String oldCache = getCachePath(oldPath);
@ -80,7 +78,7 @@ bool BookCacheManager::migrateCache(const String& oldPath, const String& newPath
} }
} }
return true; // No old cache to migrate return true; // No old cache to migrate
} }
String BookCacheManager::getCachePath(const String& path) { String BookCacheManager::getCachePath(const String& path) {
@ -91,13 +89,15 @@ String BookCacheManager::getCachePath(const String& path) {
} }
bool BookCacheManager::isSupportedFile(const String& path) { bool BookCacheManager::isSupportedFile(const String& path) {
return StringUtils::checkFileExtension(path, ".epub") || StringUtils::checkFileExtension(path, ".txt") || return StringUtils::checkFileExtension(path, ".epub") ||
StringUtils::checkFileExtension(path, ".xtc") || StringUtils::checkFileExtension(path, ".xtg") || StringUtils::checkFileExtension(path, ".txt") ||
StringUtils::checkFileExtension(path, ".xtc") ||
StringUtils::checkFileExtension(path, ".xtg") ||
StringUtils::checkFileExtension(path, ".xth"); StringUtils::checkFileExtension(path, ".xth");
} }
String BookCacheManager::getCachePrefix(const String& path) { String BookCacheManager::getCachePrefix(const String& path) {
if (StringUtils::checkFileExtension(path, ".epub")) return "epub"; if (StringUtils::checkFileExtension(path, ".epub")) return "epub";
if (StringUtils::checkFileExtension(path, ".txt")) return "txt"; if (StringUtils::checkFileExtension(path, ".txt")) return "txt";
return "xtc"; // .xtc, .xtg, .xth return "xtc"; // .xtc, .xtg, .xth
} }

View File

@ -2,7 +2,6 @@
#include <SDCardManager.h> #include <SDCardManager.h>
#include <WString.h> #include <WString.h>
#include <string> #include <string>
class BookCacheManager { class BookCacheManager {