@@ -1524,64 +1524,65 @@ void MyMesh::checkCLIRescueCmd() {
15241524
15251525 // get path from command e.g: "ls /adafruit"
15261526 const char *path = &cli_command[3 ];
1527-
1528- // log each file and directory
1529- File root = _store->openRead (path);
1530- if (root){
1531- File file = root.openNextFile ();
1532- while (file) {
1533-
1534- #if defined(EXTRAFS) || defined(QSPIFLASH)
1535- if (file.isDirectory ()) {
1536- Serial.printf (" [dir] /FS1/%s\n " , file.name ());
1537- } else {
1538- Serial.printf (" [file] /FS1/%s (%d bytes)\n " , file.name (), file.size ());
1539- }
1540- #else
1541- if (file.isDirectory ()) {
1542- Serial.printf (" [dir] %s\n " , file.name ());
1543- } else {
1544- Serial.printf (" [file] %s (%d bytes)\n " , file.name (), file.size ());
1545- }
1546- #endif
1547- // move to next file
1548- file = root.openNextFile ();
15491527
1550- }
1551- root.close ();
1528+ bool is_fs2 = false ;
1529+ if (memcmp (path, " UserData/" , 9 ) == 0 ) {
1530+ path += 8 ; // skip "UserData"
1531+ } else if (memcmp (path, " ExtraFS/" , 8 ) == 0 ) {
1532+ path += 7 ; // skip "ExtraFS"
1533+ is_fs2 = true ;
15521534 }
1553- #if defined(EXTRAFS) || defined(QSPIFLASH)
1554- root = _store->openRead (_store->getSecondaryFS (), path);
1555- if (root){
1535+ Serial.printf (" Listing files in %s\n " , path);
1536+
1537+ // log each file and directory
1538+ File root = _store->openRead (path);
1539+ if (is_fs2 == false ) {
1540+ if (root) {
15561541 File file = root.openNextFile ();
15571542 while (file) {
1558-
15591543 if (file.isDirectory ()) {
1560- Serial.printf (" [dir] /FS2/ %s\n " , file.name ());
1544+ Serial.printf (" [dir] UserData%s/ %s\n " , path , file.name ());
15611545 } else {
1562- Serial.printf (" [file] /FS2/ %s (%d bytes)\n " , file.name (), file.size ());
1546+ Serial.printf (" [file] UserData%s/ %s (%d bytes)\n " , path , file.name (), file.size ());
15631547 }
1564-
15651548 // move to next file
15661549 file = root.openNextFile ();
1567-
15681550 }
1569- root.close ();
1551+ root.close ();
1552+ }
15701553 }
1571- #endif
15721554
1555+ if (is_fs2 == true || strlen (path) == 0 || strcmp (path, " /" ) == 0 ) {
1556+ if (_store->getSecondaryFS () != nullptr ) {
1557+ File root2 = _store->openRead (_store->getSecondaryFS (), path);
1558+ File file = root2.openNextFile ();
1559+ while (file) {
1560+ if (file.isDirectory ()) {
1561+ Serial.printf (" [dir] ExtraFS%s/%s\n " , path, file.name ());
1562+ } else {
1563+ Serial.printf (" [file] ExtraFS%s/%s (%d bytes)\n " , path, file.name (), file.size ());
1564+ }
1565+ // move to next file
1566+ file = root2.openNextFile ();
1567+ }
1568+ root2.close ();
1569+ }
1570+ }
15731571 } else if (memcmp (cli_command, " cat" , 3 ) == 0 ) {
15741572
15751573 // get path from command e.g: "cat /contacts3"
15761574 const char *path = &cli_command[4 ];
15771575
1578- //
15791576 bool is_fs2 = false ;
1580- if (memcmp (path, " FS1 /" , 4 ) == 0 ) {
1581- path += 3 ; // skip "FS1 "
1582- } else if (memcmp (path, " FS2 /" , 4 ) == 0 ) {
1583- path += 3 ; // skip "FS2 "
1577+ if (memcmp (path, " UserData /" , 9 ) == 0 ) {
1578+ path += 8 ; // skip "UserData "
1579+ } else if (memcmp (path, " ExtraFS /" , 8 ) == 0 ) {
1580+ path += 7 ; // skip "ExtraFS "
15841581 is_fs2 = true ;
1582+ } else {
1583+ Serial.println (" Invalid path provided, must start with UserData/ or ExtraFS/" );
1584+ cli_command[0 ] = 0 ;
1585+ return ;
15851586 }
15861587
15871588 // log file content as hex
@@ -1605,29 +1606,28 @@ void MyMesh::checkCLIRescueCmd() {
16051606 }
16061607
16071608 } else if (memcmp (cli_command, " rm " , 3 ) == 0 ) {
1608-
16091609 // get path from command e.g: "rm /adv_blobs"
1610- const char *path = &cli_command[4 ];
1610+ const char *path = &cli_command[3 ];
16111611 MESH_DEBUG_PRINTLN (" Removing file: %s" , path);
16121612 // ensure path is not empty, or root dir
16131613 if (!path || strlen (path) == 0 || strcmp (path, " /" ) == 0 ){
16141614 Serial.println (" Invalid path provided" );
16151615 } else {
1616- bool is_fs2 = false ;
1617- if (memcmp (path, " FS1 /" , 4 ) == 0 ) {
1618- path += 3 ; // skip "FS1 "
1619- } else if (memcmp (path, " FS2 /" , 4 ) == 0 ) {
1620- path += 3 ; // skip "FS2 "
1621- is_fs2 = true ;
1622- }
1616+ bool is_fs2 = false ;
1617+ if (memcmp (path, " UserData /" , 9 ) == 0 ) {
1618+ path += 8 ; // skip "UserData "
1619+ } else if (memcmp (path, " ExtraFS /" , 8 ) == 0 ) {
1620+ path += 7 ; // skip "ExtraFS "
1621+ is_fs2 = true ;
1622+ }
16231623
16241624 // remove file
16251625 bool removed;
16261626 if (is_fs2) {
1627- MESH_DEBUG_PRINTLN (" Removing file from FS2 : %s" , path);
1627+ MESH_DEBUG_PRINTLN (" Removing file from ExtraFS : %s" , path);
16281628 removed = _store->removeFile (_store->getSecondaryFS (), path);
16291629 } else {
1630- MESH_DEBUG_PRINTLN (" Removing file from FS1 : %s" , path);
1630+ MESH_DEBUG_PRINTLN (" Removing file from UserData : %s" , path);
16311631 removed = _store->removeFile (path);
16321632 }
16331633 if (removed){
0 commit comments