mirror of
https://github.com/ALLFATHER-BV/wadamesh.git
synced 2026-10-23 21:32:33 +00:00
fix(storage): only judge the profile-tree root absent
sdProfileTreeContainsFile() re-stat'ed every recursive child with SD.exists() before opening it. The child came straight from openNextFile(), so it provably exists; the check can only ever produce a false negative, and false is the single verdict that lets a residual foreign subtree read as empty and the card get claimed. Every other uncertainty in this function already fails closed. Keep the check at the root, where "/meshcomod is absent" genuinely means there is nothing to conflict with, and let the open() fail-closed path govern below it. Signed-off-by: Pixel Perfect <me@pixp.cc>
This commit is contained in:
1 file changed
+6
-1
+6
-1
@@ -237,7 +237,12 @@ static constexpr const char* kSdMigrationOwner = "/meshcomod/.spiffs-migration-v
|
||||
static constexpr const char* kSdMigrationOwnerTmp = "/meshcomod/.spiffs-migration-v1.owner.tmp";
|
||||
|
||||
static bool sdProfileTreeContainsFile(const char* path, uint8_t depth = 0) {
|
||||
if (!SD.exists(path)) return false;
|
||||
// Only the root may be judged absent. A recursive child came straight from
|
||||
// openNextFile(), so it provably exists and re-stat'ing it can only produce a
|
||||
// false negative — which would be the one verdict that lets a foreign
|
||||
// residual subtree read as empty and get claimed. Below the root, let the
|
||||
// open() fail-closed path govern instead.
|
||||
if (depth == 0 && !SD.exists(path)) return false;
|
||||
if (depth >= 8) return true; // unexpected/deep content is not safe to adopt
|
||||
File dir = SD.open(path, FILE_READ);
|
||||
if (!dir) return true; // unreadable content is not an empty profile
|
||||
|
||||
Reference in new issue
Block a user