From d00e7bc92d5146586376aea8d8bf2d12a4d73c9a Mon Sep 17 00:00:00 2001 From: Niklas Jensen Date: Thu, 15 Jan 2026 20:11:55 +0100 Subject: [PATCH] Only flush periodically (every 64 chunks) --- esp32/src/filesystem_ws.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/esp32/src/filesystem_ws.cpp b/esp32/src/filesystem_ws.cpp index 0fe6a2d..d749a93 100644 --- a/esp32/src/filesystem_ws.cpp +++ b/esp32/src/filesystem_ws.cpp @@ -317,8 +317,11 @@ socket_message_FSUploadChunkResponse FileSystemHandler::handleUploadChunk(const return fs_up_response; } - // Flush to ensure data is written - state.file.flush(); + // Flush periodically to prevent LittleFS buffer issues (every 64 chunks = ~64KB with 1KB chunks) + if (state.chunksProcessed > 0 && state.chunksProcessed % 64 == 0) { + ESP_LOGI(TAG, "Flushing file at chunk %u", state.chunksProcessed); + state.file.flush(); + } state.chunksProcessed++; fs_up_response.success = true;