| 399 | } |
| 400 | |
| 401 | void handleUpdateActions(AsyncWebServerRequest* request) { |
| 402 | wsSerial("Performing cleanup"); |
| 403 | File file = contentFS->open("/update_actions.json", "r"); |
| 404 | if (!file) { |
| 405 | wsSerial("No update_actions.json present"); |
| 406 | request->send(200, "No update actions needed"); |
| 407 | return; |
| 408 | } |
| 409 | JsonDocument doc; |
| 410 | DeserializationError error = deserializeJson(doc, file); |
| 411 | const JsonArray deleteFiles = doc["deletefile"].as<JsonArray>(); |
| 412 | for (const auto& filePath : deleteFiles) { |
| 413 | if (contentFS->remove(filePath.as<const char*>())) { |
| 414 | wsSerial("deleted file: " + filePath.as<String>()); |
| 415 | } |
| 416 | } |
| 417 | file.close(); |
| 418 | wsSerial("Cleanup finished"); |
| 419 | request->send(200, "Clean up finished"); |
| 420 | contentFS->remove("/update_actions.json"); |
| 421 | } |