Upped chunk size to 16kb (down not working)
This commit is contained in:
committed by
Rune Harlyk
parent
d00e7bc92d
commit
1b6ffc4641
@@ -12,7 +12,7 @@ import type {
|
||||
CorrelationResponse
|
||||
} from '$lib/platform_shared/message'
|
||||
|
||||
const MAX_CHUNK_SIZE = 1024
|
||||
const MAX_CHUNK_SIZE = 2**14 // ~= 16 kb
|
||||
|
||||
export interface FileInfo {
|
||||
name: string
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#define FS_MAX_CHUNK_SIZE 1024
|
||||
// Make sure that this aligns with socket_message.FSDownloadChunkResponse.data max_size (and for the corresponsing request)
|
||||
#define FS_MAX_CHUNK_SIZE 2**14 // ~= 16 kb
|
||||
#define FS_TRANSFER_TIMEOUT 30000 // 30 seconds
|
||||
|
||||
namespace FileSystemWS {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <filesystem.h>
|
||||
#include <pb_encode.h>
|
||||
#include <pb_decode.h>
|
||||
#include <esp_littlefs.h>
|
||||
|
||||
static const char* TAG = "FileSystemWS";
|
||||
|
||||
@@ -307,6 +308,17 @@ socket_message_FSUploadChunkResponse FileSystemHandler::handleUploadChunk(const
|
||||
TransferState& state = it->second;
|
||||
state.lastActivityTime = millis();
|
||||
|
||||
// Check available space before writing
|
||||
size_t fs_total = 0, fs_used = 0;
|
||||
esp_littlefs_info("spiffs", &fs_total, &fs_used);
|
||||
size_t freeSpace = fs_total - fs_used;
|
||||
if (freeSpace < req.data.size + 4096) { // 4KB safety margin
|
||||
fs_up_response.success = false;
|
||||
strncpy(fs_up_response.error, "Filesystem full", sizeof(fs_up_response.error) - 1);
|
||||
state.file.close();
|
||||
transfers_.erase(it);
|
||||
return fs_up_response;
|
||||
}
|
||||
// Write chunk data
|
||||
size_t bytesWritten = state.file.write(req.data.bytes, req.data.size);
|
||||
if (bytesWritten != req.data.size) {
|
||||
|
||||
@@ -60,7 +60,7 @@ socket_message.FSDownloadStartResponse.transfer_id max_size:64
|
||||
|
||||
socket_message.FSDownloadChunkRequest.transfer_id max_size:64
|
||||
socket_message.FSDownloadChunkResponse.transfer_id max_size:64
|
||||
socket_message.FSDownloadChunkResponse.data max_size:1024
|
||||
socket_message.FSDownloadChunkResponse.data max_size:16384
|
||||
socket_message.FSDownloadChunkResponse.error max_size:128
|
||||
|
||||
socket_message.FSUploadStartRequest.path max_size:256
|
||||
@@ -68,7 +68,7 @@ socket_message.FSUploadStartResponse.error max_size:128
|
||||
socket_message.FSUploadStartResponse.transfer_id max_size:64
|
||||
|
||||
socket_message.FSUploadChunkRequest.transfer_id max_size:64
|
||||
socket_message.FSUploadChunkRequest.data max_size:1024
|
||||
socket_message.FSUploadChunkRequest.data max_size:16384
|
||||
socket_message.FSUploadChunkResponse.transfer_id max_size:64
|
||||
socket_message.FSUploadChunkResponse.error max_size:128
|
||||
|
||||
|
||||
Reference in New Issue
Block a user