mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-05 15:17:37 +03:00
## Summary When uploading or downloading an updated ebook from SD/WebUI/OPDS with same the filename the `.crosspoint` cache is not cleared. This can lead to issues with the Table of Contents and hangs when switching between chapters. I encountered this issue in two places: - When I need to do further ePub cleaning using Calibre after I load an ePub and find that some of its formatting should be cleaned up. When I reprocess the same book and want to place it back in the same location I need a way to invalidate the cache. - When syncing RSS feed generated epubs. I generate news ePubs with filenames like `news-outlet.epub` and so every day when I fetch new news the crosspoint cache needs to be cleared to load that file. This change offers the following features: - On web uploads, if the file already exists, the cache for that file is cleared - On OPDS downloads, if the file already exists, the cache for that file is cleared - There's now an action for `Clear Cache` in the Settings page which can clear the cache for all books Addresses https://github.com/crosspoint-reader/crosspoint-reader/issues/281 --- ### 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? PARTIALLY --------- Co-authored-by: Dave Allie <dave@daveallie.com>
29 lines
893 B
C++
29 lines
893 B
C++
#pragma once
|
|
|
|
#include <WString.h>
|
|
|
|
#include <string>
|
|
|
|
namespace StringUtils {
|
|
|
|
/**
|
|
* Sanitize a string for use as a filename.
|
|
* Replaces invalid characters with underscores, trims spaces/dots,
|
|
* and limits length to maxLength characters.
|
|
*/
|
|
std::string sanitizeFilename(const std::string& name, size_t maxLength = 100);
|
|
|
|
/**
|
|
* Check if the given filename ends with the specified extension (case-insensitive).
|
|
*/
|
|
bool checkFileExtension(const std::string& fileName, const char* extension);
|
|
bool checkFileExtension(const String& fileName, const char* extension);
|
|
|
|
// UTF-8 safe string truncation - removes one character from the end
|
|
// Returns the new size after removing one UTF-8 character
|
|
size_t utf8RemoveLastChar(std::string& str);
|
|
|
|
// Truncate string by removing N UTF-8 characters from the end
|
|
void utf8TruncateChars(std::string& str, size_t numChars);
|
|
} // namespace StringUtils
|