Skip to content

Commit

Permalink
added file removal from global and download FS (#56)
Browse files Browse the repository at this point in the history
Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
  • Loading branch information
eckelj committed Dec 18, 2023
1 parent eb9bf76 commit 1f5cd0b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
24 changes: 21 additions & 3 deletions tasmota/tasmota_xdrv_driver/xdrv_129_rddl_network.ino
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,27 @@ void RemoveFiles(){
deleteOldestFiles(500);
}

extern fs::FS* TfsFileSysHandle();
void deleteOldestFiles( int count ) {
FS* filesystem = TfsFileSysHandle();
extern fs::FS* TfsGlobalFileSysHandle();
extern fs::FS* TfsFlashFileSysHandle();
extern fs::FS* TfsDownloadFileSysHandle();

#define MAX_FILES 10000

void deleteOldestFiles( int count ){
FS* filesystem = TfsGlobalFileSysHandle();
if( filesystem )
deleteOldestFilesFromFS( filesystem, count);

filesystem = TfsFlashFileSysHandle();
if( filesystem )
deleteOldestFilesFromFS( filesystem, count);

filesystem = TfsDownloadFileSysHandle();
if( filesystem )
deleteOldestFilesFromFS( filesystem, count);
}

void deleteOldestFilesFromFS( FS* filesystem, int count ) {
if( !filesystem )
Serial.println("Failed to mount file system");

Expand Down
12 changes: 11 additions & 1 deletion tasmota/tasmota_xdrv_driver/xdrv_50_filesystem.ino
Original file line number Diff line number Diff line change
Expand Up @@ -365,11 +365,21 @@ size_t TfsFileSize(const char *fname){
return flen;
}

fs::FS* TfsFileSysHandle(){
fs::FS* TfsGlobalFileSysHandle(){
if (!ffs_type) { return nullptr; }
return ufsp;
}

fs::FS* TfsFlashFileSysHandle(){
if (!ffs_type) { return nullptr; }
return ffsp;
}

fs::FS* TfsDownloadFileSysHandle(){
if (!ffs_type) { return nullptr; }
return dfsp;
}

bool TfsSaveFile(const char *fname, const uint8_t *buf, uint32_t len) {
if (!ffs_type) { return false; }
#ifdef USE_WEBCAM
Expand Down

0 comments on commit 1f5cd0b

Please sign in to comment.