Added console server path remapping for long filenames
This commit is contained in:
parent
6e03084c1b
commit
70f40e3a77
29
Console.h
29
Console.h
@ -79,6 +79,14 @@ bool console_serve_file(String path) {
|
|||||||
path += "index.html";
|
path += "index.html";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (path == "/r/manual/index.html") {
|
||||||
|
path = "/m.html"
|
||||||
|
}
|
||||||
|
if (path == "/r/manual/Reticulum Manual.pdf") {
|
||||||
|
path = "/h.html"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
String content_type = console_get_content_type(path);
|
String content_type = console_get_content_type(path);
|
||||||
String pathWithGz = path + ".gz";
|
String pathWithGz = path + ".gz";
|
||||||
if (exists(pathWithGz) || exists(path)) {
|
if (exists(pathWithGz) || exists(path)) {
|
||||||
@ -89,14 +97,31 @@ bool console_serve_file(String path) {
|
|||||||
File file = SPIFFS.open(path, "r");
|
File file = SPIFFS.open(path, "r");
|
||||||
console_dbg("Serving file to client");
|
console_dbg("Serving file to client");
|
||||||
server.streamFile(file, content_type);
|
server.streamFile(file, content_type);
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
console_dbg("File serving done\n");
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
int spos = pathWithGz.lastIndexOf('/');
|
||||||
|
if (spos > 0) {
|
||||||
|
String remap_path = "/d";
|
||||||
|
remap_path.concat(pathWithGz.substring(spos));
|
||||||
|
Serial.println(remap_path);
|
||||||
|
|
||||||
|
if (exists(remap_path)) {
|
||||||
|
File file = SPIFFS.open(remap_path, "r");
|
||||||
|
console_dbg("Serving remapped file to client");
|
||||||
|
server.streamFile(file, content_type);
|
||||||
console_dbg("Closing file");
|
console_dbg("Closing file");
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
console_dbg("File serving done");
|
console_dbg("File serving done\n");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
console_dbg("Error: Could not open file for serving");
|
console_dbg("Error: Could not open file for serving\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user