checkpoint 2 - post PR merge - debug ghosting
This commit is contained in:
parent
bc4edeef26
commit
397abe1ef0
@ -109,7 +109,7 @@ void TxtReaderActivity::onEnter() {
|
|||||||
APP_STATE.openBookTitle = txt->getTitle();
|
APP_STATE.openBookTitle = txt->getTitle();
|
||||||
APP_STATE.openBookAuthor.clear(); // TXT files don't have author metadata
|
APP_STATE.openBookAuthor.clear(); // TXT files don't have author metadata
|
||||||
APP_STATE.saveToFile();
|
APP_STATE.saveToFile();
|
||||||
RECENT_BOOKS.addBook(txt->getPath());
|
RECENT_BOOKS.addBook(txt->getPath(), txt->getTitle(), ""); // TXT files have no author metadata
|
||||||
|
|
||||||
// Trigger first update
|
// Trigger first update
|
||||||
updateRequired = true;
|
updateRequired = true;
|
||||||
|
|||||||
@ -489,69 +489,6 @@ void CrossPointWebServer::handleFileListData() const {
|
|||||||
Serial.printf("[%lu] [WEB] Served file listing page for path: %s\n", millis(), currentPath.c_str());
|
Serial.printf("[%lu] [WEB] Served file listing page for path: %s\n", millis(), currentPath.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CrossPointWebServer::handleDownload() const {
|
|
||||||
if (!server->hasArg("path")) {
|
|
||||||
server->send(400, "text/plain", "Missing path");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String itemPath = server->arg("path");
|
|
||||||
if (itemPath.isEmpty() || itemPath == "/") {
|
|
||||||
server->send(400, "text/plain", "Invalid path");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!itemPath.startsWith("/")) {
|
|
||||||
itemPath = "/" + itemPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
const String itemName = itemPath.substring(itemPath.lastIndexOf('/') + 1);
|
|
||||||
if (itemName.startsWith(".")) {
|
|
||||||
server->send(403, "text/plain", "Cannot access system files");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (size_t i = 0; i < HIDDEN_ITEMS_COUNT; i++) {
|
|
||||||
if (itemName.equals(HIDDEN_ITEMS[i])) {
|
|
||||||
server->send(403, "text/plain", "Cannot access protected items");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!SdMan.exists(itemPath.c_str())) {
|
|
||||||
server->send(404, "text/plain", "Item not found");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
FsFile file = SdMan.open(itemPath.c_str());
|
|
||||||
if (!file) {
|
|
||||||
server->send(500, "text/plain", "Failed to open file");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (file.isDirectory()) {
|
|
||||||
file.close();
|
|
||||||
server->send(400, "text/plain", "Path is a directory");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String contentType = "application/octet-stream";
|
|
||||||
if (isEpubFile(itemPath)) {
|
|
||||||
contentType = "application/epub+zip";
|
|
||||||
}
|
|
||||||
|
|
||||||
char nameBuf[128] = {0};
|
|
||||||
String filename = "download";
|
|
||||||
if (file.getName(nameBuf, sizeof(nameBuf))) {
|
|
||||||
filename = nameBuf;
|
|
||||||
}
|
|
||||||
|
|
||||||
server->setContentLength(file.size());
|
|
||||||
server->sendHeader("Content-Disposition", "attachment; filename=\"" + filename + "\"");
|
|
||||||
server->send(200, contentType.c_str(), "");
|
|
||||||
|
|
||||||
WiFiClient client = server->client();
|
|
||||||
client.write(file);
|
|
||||||
file.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Static variables for upload handling
|
// Static variables for upload handling
|
||||||
static FsFile uploadFile;
|
static FsFile uploadFile;
|
||||||
static String uploadFileName;
|
static String uploadFileName;
|
||||||
|
|||||||
@ -99,7 +99,6 @@ class CrossPointWebServer {
|
|||||||
void handleArchive() const;
|
void handleArchive() const;
|
||||||
void handleUnarchive() const;
|
void handleUnarchive() const;
|
||||||
void handleArchivedList() const;
|
void handleArchivedList() const;
|
||||||
void handleDownload() const;
|
|
||||||
void handleRename() const;
|
void handleRename() const;
|
||||||
void handleCopy() const;
|
void handleCopy() const;
|
||||||
void handleMove() const;
|
void handleMove() const;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user