mirror of
https://github.com/lumapu/ahoy.git
synced 2025-06-06 20:51:38 +02:00
0.5.102
fix JSON import #775 fix save settings, at least already stored settings are not lost #771
This commit is contained in:
parent
3e67f2a52f
commit
e1326698b9
7 changed files with 52 additions and 23 deletions
|
@ -161,26 +161,24 @@ class Web {
|
|||
DPRINTLN(DBG_ERROR, F("can't open file!"));
|
||||
mUploadFail = true;
|
||||
mUploadFp.close();
|
||||
return;
|
||||
}
|
||||
}
|
||||
mUploadFp.write(data, len);
|
||||
if (final) {
|
||||
mUploadFp.close();
|
||||
File fp = LittleFS.open("/tmp.json", "r");
|
||||
if (!fp)
|
||||
char pwd[PWD_LEN];
|
||||
strncpy(pwd, mConfig->sys.stationPwd, PWD_LEN); // backup WiFi PWD
|
||||
if (!mApp->readSettings("/tmp.json")) {
|
||||
mUploadFail = true;
|
||||
else {
|
||||
char pwd[PWD_LEN];
|
||||
strncpy(pwd, mConfig->sys.stationPwd, PWD_LEN); // backup WiFi PWD
|
||||
if (!mApp->readSettings("tmp.json")) {
|
||||
mUploadFail = true;
|
||||
DPRINTLN(DBG_ERROR, F("upload JSON error!"));
|
||||
} else {
|
||||
strncpy(mConfig->sys.stationPwd, pwd, PWD_LEN); // restore WiFi PWD
|
||||
mApp->saveSettings(true);
|
||||
}
|
||||
DPRINTLN(DBG_ERROR, F("upload JSON error!"));
|
||||
} else {
|
||||
LittleFS.remove("/tmp.json");
|
||||
strncpy(mConfig->sys.stationPwd, pwd, PWD_LEN); // restore WiFi PWD
|
||||
mApp->saveSettings(true);
|
||||
}
|
||||
DPRINTLN(DBG_INFO, F("upload finished!"));
|
||||
if (!mUploadFail)
|
||||
DPRINTLN(DBG_INFO, F("upload finished!"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue