From 07a571f68dd465665f30998e8d2c2726839d23e8 Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Sun, 9 Aug 2026 11:51:08 +0200 Subject: [PATCH] Fix for installing and running apps --- Modules/app-module/source/app_install.cpp | 12 +++++++++++- .../service/development/DevelopmentService.cpp | 6 +++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Modules/app-module/source/app_install.cpp b/Modules/app-module/source/app_install.cpp index bcbd6c8db..5202cb07c 100644 --- a/Modules/app-module/source/app_install.cpp +++ b/Modules/app-module/source/app_install.cpp @@ -231,8 +231,16 @@ error_t register_installed_app_locked(const std::string& app_dir_path, const App .flags = 0, }; + // Belt-and-braces: app_install()'s earlier app_manager_remove() call is meant to have + // already cleared any stale registration for this id (e.g. left over from + // app_manager_install_path_scan()'s separate registry), but that call happens before the + // tarball is even extracted - remove once more, right before add, so a duplicate id can + // never turn a filesystem-level install success into a reported failure. + app_manager_remove(record->id.c_str()); + error_t add_result = app_manager_add(&record->manifest); if (add_result != ERROR_NONE) { + LOG_E(TAG, "Failed to register app '%s': %s", record->id.c_str(), error_to_string(add_result)); return add_result; } @@ -362,7 +370,9 @@ error_t app_install(const char* source_path) { // uninstall_locked() doesn't know about. Clear the app-manager registration unconditionally // too, or app_manager_add() below rejects the re-add as a duplicate. uninstall_locked(metadata.app_id); - if (app_manager_remove(metadata.app_id) != ERROR_NONE) { + + error_t remove_result = app_manager_remove(metadata.app_id); + if (remove_result != ERROR_NONE && remove_result != ERROR_NOT_FOUND) { LOG_E(TAG, "Install failed: failed to remove existing installation"); mutex_unlock(®istry.mutex); delete_recursively(staging_path); diff --git a/Tactility/Source/service/development/DevelopmentService.cpp b/Tactility/Source/service/development/DevelopmentService.cpp index 530deb029..0edd78493 100644 --- a/Tactility/Source/service/development/DevelopmentService.cpp +++ b/Tactility/Source/service/development/DevelopmentService.cpp @@ -113,7 +113,7 @@ esp_err_t DevelopmentService::handleAppRun(httpd_req_t* request) { } } - app_manager_start(app_id, &instance_id); + app_manager_start(id_key_pos->second.c_str(), &instance_id); LOG_I(TAG, "[200] /app/run %s", id_key_pos->second.c_str()); httpd_resp_send(request, nullptr, 0); @@ -193,7 +193,7 @@ esp_err_t DevelopmentService::handleAppInstall(httpd_req_t* request) { LOG_W(TAG, "We have more bytes at the end of the request parsing?!"); } - if (!app_install(file_path.c_str())) { + if (app_install(file_path.c_str()) != ERROR_NONE) { httpd_resp_send_err(request, HTTPD_500_INTERNAL_SERVER_ERROR, "Failed to install"); return ESP_FAIL; } @@ -231,7 +231,7 @@ esp_err_t DevelopmentService::handleAppUninstall(httpd_req_t* request) { return ESP_OK; } - if (app_uninstall(id_key_pos->second.c_str())) { + if (app_uninstall(id_key_pos->second.c_str()) == ERROR_NONE) { LOG_I(TAG, "[200] /app/uninstall %s", id_key_pos->second.c_str()); httpd_resp_send(request, nullptr, 0); return ESP_OK;