]> git.tnoah.ca Git - lora-radio.git/commitdiff
Added console server path remapping for long filenames
authorMark Qvist <mark@unsigned.io>
Fri, 13 Jan 2023 00:12:42 +0000 (01:12 +0100)
committerMark Qvist <mark@unsigned.io>
Fri, 13 Jan 2023 00:12:42 +0000 (01:12 +0100)
Console.h
Release/spiffs.bin

index 12fd04678c4b2d2a21974f7c0a839874face77c1..0399bbd75468d08dc53cc4d5d89bb73f34f3c252 100644 (file)
--- a/Console.h
+++ b/Console.h
@@ -79,6 +79,14 @@ bool console_serve_file(String path) {
     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 pathWithGz = path + ".gz";
   if (exists(pathWithGz) || exists(path)) {
@@ -89,14 +97,31 @@ bool console_serve_file(String path) {
     File file = SPIFFS.open(path, "r");
     console_dbg("Serving file to client");
     server.streamFile(file, content_type);
-    console_dbg("Closing file");
     file.close();
 
-    console_dbg("File serving done");
+    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");
+        file.close();
+        
+        console_dbg("File serving done\n");
+        return true;
+      }
+    }
   }
 
-  console_dbg("Error: Could not open file for serving");
+  console_dbg("Error: Could not open file for serving\n");
   return false;
 }
 
index 3be16aa979e46dc4e82469e116c8aa3353dc0a03..3900aaa2988cbd5884de206d85f998a61d833848 100644 (file)
Binary files a/Release/spiffs.bin and b/Release/spiffs.bin differ