diff --git a/src/FSCommon.cpp b/src/FSCommon.cpp index 5832a2ac..ecda025c 100644 --- a/src/FSCommon.cpp +++ b/src/FSCommon.cpp @@ -9,13 +9,13 @@ bool copyFile(const char* from, const char* to) File f1 = FSCom.open(from, FILE_O_READ); if (!f1){ - DEBUG_MSG("Failed to open file"); + DEBUG_MSG("Failed to open source file %s\n", from); return false; } File f2 = FSCom.open(to, FILE_O_WRITE); if (!f2) { - DEBUG_MSG("Failed to open file"); + DEBUG_MSG("Failed to open destination file %s\n", to); return false; } @@ -56,10 +56,10 @@ void listDir(const char * dirname, uint8_t levels) while(file){ if(file.isDirectory() && !String(file.name()).endsWith(".")) { if(levels){ - listDir(file.name(), levels -1); + listDir(file.path(), levels -1); } } else { - DEBUG_MSG(" %s (%i Bytes)\n", file.name(), file.size()); + DEBUG_MSG(" %s (%i Bytes)\n", file.path(), file.size()); } file.close(); file = root.openNextFile(); @@ -94,16 +94,16 @@ void rmDir(const char * dirname) strcat(dirpath,entry.name()); // append string two to the result. if(entry.isDirectory() && !String(entry.name()).endsWith(".")) { entry.close(); - // DEBUG_MSG("Descend DIR %s\n", dirpath); + DEBUG_MSG("Descend DIR %s\n", dirpath); rmDir(dirpath); } else { entry.close(); - // DEBUG_MSG("Remove FILE %s\n", entry.name()); + DEBUG_MSG("Remove FILE %s\n", entry.name()); FSCom.remove(entry.name()); } } FSCom.rmdir(dirname); - // DEBUG_MSG("Remove DIR %s\n", dirname); + DEBUG_MSG("Remove DIR %s\n", dirname); file.close(); #endif } @@ -117,7 +117,7 @@ void fsInit() assert(0); // FIXME - report failure to phone } - DEBUG_MSG("Filesystem files:\n"); + DEBUG_MSG("Filesystem files (%d/%d total Bytes):\n", FSCom.usedBytes(), FSCom.totalBytes()); listDir("/", 10); #endif } diff --git a/src/FSCommon.h b/src/FSCommon.h index 38ca403b..2daca975 100644 --- a/src/FSCommon.h +++ b/src/FSCommon.h @@ -40,6 +40,7 @@ using namespace Adafruit_LittleFS_Namespace; #endif void fsInit(); +bool copyFile(const char* from, const char* to); bool renameFile(const char* pathFrom, const char* pathTo); void listDir(const char * dirname, uint8_t levels); void rmDir(const char * dirname); diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 15601749..4e06d263 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -431,7 +431,6 @@ bool saveProto(const char *filename, size_t protoSize, size_t objSize, const pb_ } else { okay = true; } - f.close(); // brief window of risk here ;-) @@ -454,7 +453,7 @@ void NodeDB::saveChannelsToDisk() #ifdef FSCom FSCom.mkdir("/prefs"); #endif - saveProto(channelFileName, ChannelFile_size, sizeof(ChannelFile), ChannelFile_fields, &channelFile); + saveProto(channelFileName, ChannelFile_size, sizeof(channelFile), ChannelFile_fields, &channelFile); } } @@ -484,7 +483,7 @@ void NodeDB::saveToDisk() config.has_power = true; config.has_network = true; config.has_bluetooth = true; - saveProto(configFileName, LocalConfig_size, sizeof(LocalConfig), LocalConfig_fields, &config); + saveProto(configFileName, LocalConfig_size, sizeof(config), LocalConfig_fields, &config); moduleConfig.has_canned_message = true; moduleConfig.has_external_notification = true; @@ -493,7 +492,7 @@ void NodeDB::saveToDisk() moduleConfig.has_serial = true; moduleConfig.has_store_forward = true; moduleConfig.has_telemetry = true; - saveProto(moduleConfigFileName, LocalModuleConfig_size, sizeof(LocalModuleConfig), LocalModuleConfig_fields, &moduleConfig); + saveProto(moduleConfigFileName, LocalModuleConfig_size, sizeof(moduleConfig), LocalModuleConfig_fields, &moduleConfig); saveChannelsToDisk(); } else { diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp index 240c2308..41f62062 100644 --- a/src/modules/CannedMessageModule.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -411,7 +411,7 @@ bool CannedMessageModule::saveProtoForModule() FS.mkdir("/prefs"); #endif - okay &= saveProto(cannedMessagesConfigFile, CannedMessageModuleConfig_size, sizeof(CannedMessageModuleConfig), + okay &= saveProto(cannedMessagesConfigFile, CannedMessageModuleConfig_size, sizeof(cannedMessageModuleConfig), CannedMessageModuleConfig_fields, &cannedMessageModuleConfig); return okay;