Skip to content

Commit 33d5dcd

Browse files
committed
fix nvs: blob upload add guard for 0 byte upload
1 parent 3f7e648 commit 33d5dcd

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

js/nvs-editor.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1790,6 +1790,14 @@ export class NVSEditor {
17901790
* or extend the partition; the new payload must fit in the existing slots.
17911791
*/
17921792
_uploadBlobToNVS(blob, fileBytes) {
1793+
// Refuse 0-byte uploads outright — replacing all chunks with an empty
1794+
// payload would leave the blob_index as an orphan (totalSize=0,
1795+
// chunkCount=0) which ESP-IDF NVS does not surface as a valid blob.
1796+
// Users who want to remove a blob should use the per-entry delete UI.
1797+
if (fileBytes.length === 0) {
1798+
throw new Error("Cannot upload an empty file as blob replacement.");
1799+
}
1800+
17931801
// Resolve the parsed data-chunk items (in chunk-index order) so we know
17941802
// each slot's offset/span and can size-check before mutating anything.
17951803
const sortedChunks = [...blob.chunks].sort((a, b) => a.index - b.index);

0 commit comments

Comments
 (0)