Merge pull request #14229 from gemu2015/filesyystem_fix

fix edit file gui for sd card
This commit is contained in:
Theo Arends 2022-01-01 15:29:34 +01:00 committed by GitHub
commit a02c58ab9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -978,15 +978,15 @@ void UfsEditor(void) {
char fname[UFS_FILENAME_SIZE]; char fname[UFS_FILENAME_SIZE];
UfsFilename(fname, fname_input); // Trim spaces and add slash UfsFilename(fname, fname_input); // Trim spaces and add slash
AddLog(LOG_LEVEL_DEBUG, PSTR("UFS: UfsEditor: file=%s, ffs_type=%d, TfsFileExist=%d"), fname, ffs_type, TfsFileExists(fname)); AddLog(LOG_LEVEL_DEBUG, PSTR("UFS: UfsEditor: file=%s, ffs_type=%d, TfsFileExist=%d"), fname, ffs_type, dfsp->exists(fname));
WSContentStart_P(PSTR(D_EDIT_FILE)); WSContentStart_P(PSTR(D_EDIT_FILE));
WSContentSendStyle(); WSContentSendStyle();
char *bfname = fname +1; char *bfname = fname +1;
WSContentSend_P(HTTP_EDITOR_FORM_START, bfname); // Skip leading slash WSContentSend_P(HTTP_EDITOR_FORM_START, bfname); // Skip leading slash
if (ffs_type && TfsFileExists(fname)) { if (ffs_type && dfsp->exists(fname)) {
File fp = ffsp->open(fname, "r"); File fp = dfsp->open(fname, "r");
if (!fp) { if (!fp) {
AddLog(LOG_LEVEL_DEBUG, PSTR("UFS: UfsEditor: file open failed")); AddLog(LOG_LEVEL_DEBUG, PSTR("UFS: UfsEditor: file open failed"));
WSContentSend_P(D_NEW_FILE); WSContentSend_P(D_NEW_FILE);
@ -1039,14 +1039,14 @@ void UfsEditorUpload(void) {
} }
String content = Webserver->arg("content"); String content = Webserver->arg("content");
if (!ffsp) { if (!dfsp) {
Web.upload_error = 1; Web.upload_error = 1;
AddLog(LOG_LEVEL_ERROR, PSTR("UFS: UfsEditor: 507: no storage available")); AddLog(LOG_LEVEL_ERROR, PSTR("UFS: UfsEditor: 507: no storage available"));
WSSend(507, CT_PLAIN, F("507: no storage available")); WSSend(507, CT_PLAIN, F("507: no storage available"));
return; return;
} }
File fp = ffsp->open(fname, "w"); File fp = dfsp->open(fname, "w");
if (!fp) { if (!fp) {
Web.upload_error = 1; Web.upload_error = 1;
AddLog(LOG_LEVEL_ERROR, PSTR("UFS: UfsEditor: 400: invalid file name '%s'"), fname); AddLog(LOG_LEVEL_ERROR, PSTR("UFS: UfsEditor: 400: invalid file name '%s'"), fname);