More missing unlocks

This commit is contained in:
GUVWAF 2024-12-18 21:03:20 +01:00
parent 390b396c61
commit 12f0df49a1
2 changed files with 9 additions and 2 deletions

View File

@ -101,12 +101,14 @@ bool copyFile(const char *from, const char *to)
File f1 = FSCom.open(from, FILE_O_READ);
if (!f1) {
LOG_ERROR("Failed to open source file %s", from);
spiLock->unlock();
return false;
}
File f2 = FSCom.open(to, FILE_O_WRITE);
if (!f2) {
LOG_ERROR("Failed to open destination file %s", to);
spiLock->unlock();
return false;
}
@ -145,8 +147,9 @@ bool renameFile(const char *pathFrom, const char *pathTo)
// take SPI Lock
spiLock->lock();
// rename was fixed for ESP32 IDF LittleFS in April
return FSCom.rename(pathFrom, pathTo);
bool result = FSCom.rename(pathFrom, pathTo);
spiLock->unlock();
return result;
#else
// copyFile does its own locking.
if (copyFile(pathFrom, pathTo) && FSCom.remove(pathFrom)) {

View File

@ -213,11 +213,13 @@ bool RangeTestModuleRadio::appendFile(const meshtastic_MeshPacket &mp)
spiLock->lock();
if (!FSBegin()) {
LOG_DEBUG("An Error has occurred while mounting the filesystem");
spiLock->unlock();
return 0;
}
if (FSCom.totalBytes() - FSCom.usedBytes() < 51200) {
LOG_DEBUG("Filesystem doesn't have enough free space. Aborting write");
spiLock->unlock();
return 0;
}
@ -230,6 +232,7 @@ bool RangeTestModuleRadio::appendFile(const meshtastic_MeshPacket &mp)
if (!fileToWrite) {
LOG_ERROR("There was an error opening the file for writing");
spiLock->unlock();
return 0;
}
@ -249,6 +252,7 @@ bool RangeTestModuleRadio::appendFile(const meshtastic_MeshPacket &mp)
if (!fileToAppend) {
LOG_ERROR("There was an error opening the file for appending");
spiLock->unlock();
return 0;
}