Strip trailing slashes from dir-path constants

PATH_CONTACTS / PATH_MESSAGES / SD_PATH_CONTACTS / SD_PATH_MESSAGES
all ended in '/'. The FATFS layer used by the SD library and LittleFS
won't reliably enumerate when given a path ending in slash — opendir
returns a valid handle but readdir yields nothing. Direct file reads
(SD.open with FILE_READ for a known path) still work, which is why
settings/identity persisted but contacts and conversations vanished
on reboot.

Drop the trailing slash from the constants and add explicit "/" at
all concat sites: saveContact, removeContact, conversationDir,
sdConversationDir, and the migrateTruncatedDirs path builders.
This commit is contained in:
drkhsh committed 2026-04-26 02:50:54 +02:00
1 parent 9cb5a4f3db
commit 3d135ceca1
3 files changed
+15 -12

No files matched your search

+4 -4
View File
@@ -349,15 +349,15 @@ void AnnounceManager::saveContact(const DiscoveredNode& node) {
serializeJson(doc, json);
String filename = hexHash.substr(0, 16).c_str();
filename += ".json";
if (_sd && _sd->isReady()) { _sd->writeString((String(SD_PATH_CONTACTS) + filename).c_str(), json); }
if (_flash) { _flash->writeString((String(PATH_CONTACTS) + filename).c_str(), json); }
if (_sd && _sd->isReady()) { _sd->writeString((String(SD_PATH_CONTACTS) + "/" + filename).c_str(), json); }
if (_flash) { _flash->writeString((String(PATH_CONTACTS) + "/" + filename).c_str(), json); }
}
void AnnounceManager::removeContact(const std::string& hexHash) {
String filename = hexHash.substr(0, 16).c_str();
filename += ".json";
if (_sd && _sd->isReady()) { _sd->remove((String(SD_PATH_CONTACTS) + filename).c_str()); }
if (_flash) { _flash->remove((String(PATH_CONTACTS) + filename).c_str()); }
if (_sd && _sd->isReady()) { _sd->remove((String(SD_PATH_CONTACTS) + "/" + filename).c_str()); }
if (_flash) { _flash->remove((String(PATH_CONTACTS) + "/" + filename).c_str()); }
}
bool AnnounceManager::deleteContact(int nodeIdx) {