minor changes

This commit is contained in:
Stefan Ostermann 2025-07-27 22:28:21 +02:00
parent ce4ef44dcd
commit 571a1c5c39
2 changed files with 10 additions and 3 deletions

View File

@ -467,6 +467,9 @@ String DirectoryNode::getCurrentPlayingFilePath() const
if (currentPlaying != nullptr)
{
String filePath = name;
if (!filePath.startsWith("/")) {
filePath = "/"+filePath;
}
if (!filePath.endsWith("/"))
{
filePath += "/";

View File

@ -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);