From bad8a061eeaeaf1eda1d5e969da84a4240ec93fe Mon Sep 17 00:00:00 2001 From: R0ck Date: Sat, 21 Nov 2026 01:47:47 +0000 Subject: [PATCH] shim: open FILE_O_WRITE without truncating, as meshcore-native does --- internal/mesh/shim/repeater/InternalFileSystem.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/mesh/shim/repeater/InternalFileSystem.h b/internal/mesh/shim/repeater/InternalFileSystem.h index cbd399fe..66337cf9 100644 --- a/internal/mesh/shim/repeater/InternalFileSystem.h +++ b/internal/mesh/shim/repeater/InternalFileSystem.h @@ -125,7 +125,15 @@ class Adafruit_LittleFS { // this fails, and it fails silently as a null file. auto slash = p.find_last_of('/'); if (slash != std::string::npos) ensureDir(p.substr(0, slash)); - FILE* f = fopen(p.c_str(), mode); + // FILE_O_WRITE as LittleFS opens it on nRF52: not truncated, at the end. + FILE* f; + if (strcmp(mode, FILE_O_WRITE) == 0) { + f = fopen(p.c_str(), "r+b"); + if (!f) f = fopen(p.c_str(), "w+b"); + if (f) fseek(f, 0, SEEK_END); + } else { + f = fopen(p.c_str(), mode); + } return File(f, p); }