Compare commits

...

2 Commits

Author SHA1 Message Date
GUVWAF
12f0df49a1 More missing unlocks 2024-12-18 21:03:20 +01:00
GUVWAF
390b396c61 Add missing unlock 2024-12-18 20:50:05 +01:00
3 changed files with 11 additions and 3 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

@ -43,6 +43,7 @@ bool readcb(pb_istream_t *stream, uint8_t *buf, size_t count)
if (buf == NULL) {
while (count-- && file->read() != EOF)
;
spiLock->unlock();
return count == 0;
}
@ -75,4 +76,4 @@ bool is_in_helper(uint32_t n, const uint32_t *array, pb_size_t count)
return true;
return false;
}
}

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;
}
@ -295,4 +299,4 @@ bool RangeTestModuleRadio::appendFile(const meshtastic_MeshPacket &mp)
#endif
return 1;
}
}