fix: FTP storage type (SD_MMC not FFAT), SD used-space walk
- Define FTP_SERVER_NETWORK_TYPE=6 and STORAGE_TYPE=10 directly to bypass FtpServerKey.h platform detection that was overriding storage to FFAT - Fix calcDirSize: properly close files, use name() for recursive path - Add SD debug logging for used-space calculation - This fixes file transfers (read/write) failing via FTP
This commit is contained in:
+11
-5
@@ -105,15 +105,18 @@ static uint64_t calcDirSize(fs::FS &fs, const char *dirname) {
|
||||
uint64_t total = 0;
|
||||
File root = fs.open(dirname);
|
||||
if (!root || !root.isDirectory()) return 0;
|
||||
File f = root.openNextFile();
|
||||
while (f) {
|
||||
File f;
|
||||
while ((f = root.openNextFile())) {
|
||||
if (f.isDirectory()) {
|
||||
total += calcDirSize(fs, f.path());
|
||||
String path = f.name();
|
||||
f.close();
|
||||
total += calcDirSize(fs, path.c_str());
|
||||
} else {
|
||||
total += f.size();
|
||||
f.close();
|
||||
}
|
||||
f = root.openNextFile();
|
||||
}
|
||||
root.close();
|
||||
return total;
|
||||
}
|
||||
|
||||
@@ -121,9 +124,12 @@ static void updateSdInfo() {
|
||||
if (!sd_ok) return;
|
||||
uint64_t total = SD_MMC.totalBytes() / (1024ULL * 1024ULL);
|
||||
uint64_t used = SD_MMC.usedBytes() / (1024ULL * 1024ULL);
|
||||
Serial.printf("[SD] API: used=%llu MB, total=%llu MB\n", used, total);
|
||||
/* SD_MMC.usedBytes() returns 0 on exFAT / large cards — walk filesystem */
|
||||
if (used == 0 && total > 0) {
|
||||
used = calcDirSize(SD_MMC, "/") / (1024ULL * 1024ULL);
|
||||
uint64_t walked = calcDirSize(SD_MMC, "/");
|
||||
used = walked / (1024ULL * 1024ULL);
|
||||
Serial.printf("[SD] Walk: %llu bytes = %llu MB\n", walked, used);
|
||||
}
|
||||
ui_set_sd(used, total);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user