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:
+4
-2
@@ -36,11 +36,13 @@ build_flags =
|
||||
-Wl,--wrap=esp_ota_mark_app_valid_cancel_rollback
|
||||
; Enable LVGL simple include
|
||||
-DLV_CONF_INCLUDE_SIMPLE
|
||||
; FTP server: must define BOTH network + storage with numeric values
|
||||
; to prevent FtpServerKey.h from defaulting to FFAT
|
||||
; FTP server: define STORAGE_TYPE and FTP_SERVER_NETWORK_TYPE directly
|
||||
; to bypass FtpServerKey.h platform detection entirely
|
||||
; NETWORK_ESP32=6, STORAGE_SD_MMC=10
|
||||
-DDEFAULT_FTP_SERVER_NETWORK_TYPE_ESP32=6
|
||||
-DDEFAULT_STORAGE_TYPE_ESP32=10
|
||||
-DFTP_SERVER_NETWORK_TYPE=6
|
||||
-DSTORAGE_TYPE=10
|
||||
; Suppress deprecation warnings
|
||||
-Wno-deprecated-declarations
|
||||
; Allow #warning without failing build
|
||||
|
||||
+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