From 7e843634800f0e11d62648afc0c4c42fe0132cce Mon Sep 17 00:00:00 2001 From: Daniel Skinstad Drabitzius Date: Mon, 3 Feb 2025 16:41:27 +0100 Subject: [PATCH] chore: explicit error for no files in zephyr-image-update-module Check if the aritfact has a payload file by adding a boolean that's set when the download artifact flash callback is called. Ticket: MEN-7804 Signed-off-by: Daniel Skinstad Drabitzius --- core/src/mender-zephyr-image-update-module.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/src/mender-zephyr-image-update-module.c b/core/src/mender-zephyr-image-update-module.c index 54bb6d05..3a66402f 100644 --- a/core/src/mender-zephyr-image-update-module.c +++ b/core/src/mender-zephyr-image-update-module.c @@ -29,6 +29,8 @@ */ static void *mcu_boot_flash_handle = NULL; +static bool artifact_had_payload; + /** * @brief Callback function to be invoked to perform the treatment of the data from the artifact type "zephyr-image" * @return MENDER_OK if the function succeeds, error code if an error occurred @@ -126,6 +128,7 @@ mender_zephyr_image_download_artifact_flash_callback(MENDER_NDEBUG_UNUSED mender } } + artifact_had_payload = true; END: return ret; @@ -136,6 +139,12 @@ mender_zephyr_image_set_pending_image(MENDER_NDEBUG_UNUSED mender_update_state_t assert(MENDER_UPDATE_STATE_INSTALL == state); mender_err_t ret; + if (!artifact_had_payload) { + mender_log_error("No payload in artifact"); + return MENDER_FAIL; + } + artifact_had_payload = false; + if (NULL == mcu_boot_flash_handle) { mender_log_error("Set pending image requested but handle is cleared"); return MENDER_FAIL; @@ -157,6 +166,7 @@ mender_zephyr_image_abort_deployment(MENDER_NDEBUG_UNUSED mender_update_state_t mender_log_error("Unable to abort deployment"); return ret; } + artifact_had_payload = false; return MENDER_OK; }