From 571a1c5c3932a76547936786fdd440c3d6f74f0e Mon Sep 17 00:00:00 2001 From: Stefan Ostermann Date: Sun, 27 Jul 2025 22:28:21 +0200 Subject: [PATCH] minor changes --- src/DirectoryNode.cpp | 3 +++ src/main.cpp | 10 +++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/DirectoryNode.cpp b/src/DirectoryNode.cpp index a4f0322..85e8226 100644 --- a/src/DirectoryNode.cpp +++ b/src/DirectoryNode.cpp @@ -467,6 +467,9 @@ String DirectoryNode::getCurrentPlayingFilePath() const if (currentPlaying != nullptr) { String filePath = name; + if (!filePath.startsWith("/")) { + filePath = "/"+filePath; + } if (!filePath.endsWith("/")) { filePath += "/"; diff --git a/src/main.cpp b/src/main.cpp index 1385f68..42c8fb1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -222,7 +222,7 @@ void handleUpload(AsyncWebServerRequest *request, String filename, size_t index, } // Flush data periodically to ensure it's written - if (index % 4096 == 0) { // Flush every 4KB + if (index % 2048 == 0) { // Flush every 2KB request->_tempFile.flush(); } @@ -262,8 +262,10 @@ void handleMoveFile(AsyncWebServerRequest *request) { String to = request->arg("to"); if (SD.exists(from)) { - SD.rename(from.c_str(), to.c_str()); + SD.rename(from, to); Serial.println("Moved file: " + from + " to " + to); + // Rebuild directory tree to update file list + rootNode.buildDirectoryTree("/"); request->send(200, "text/plain", "File moved successfully."); } else { Serial.println("File not found: " + from); @@ -275,8 +277,10 @@ void handleDeleteFile(AsyncWebServerRequest *request) { String filename = request->arg("filename"); if (SD.exists(filename)) { - SD.remove(filename); + SD.remove(filename.c_str()); Serial.println("Deleted file: " + filename); + // Rebuild directory tree to update file list + rootNode.buildDirectoryTree("/"); request->send(200, "text/plain", "File deleted successfully."); } else { Serial.println("File not found: " + filename);