Skip to content

Commit

Permalink
chore: explicit error for no files in zephyr-image-update-module
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
danielskinstad committed Feb 3, 2025
1 parent f83e2ae commit fbf1f55
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions core/src/mender-zephyr-image-update-module.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
*/
static void *mcu_boot_flash_handle = NULL;

static bool artifact_has_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
Expand Down Expand Up @@ -126,6 +128,7 @@ mender_zephyr_image_download_artifact_flash_callback(MENDER_NDEBUG_UNUSED mender
}
}

artifact_has_payload = true;
END:

return ret;
Expand All @@ -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_has_payload) {
mender_log_error("No file in artifact");
return MENDER_FAIL;
}
artifact_has_payload = false;

if (NULL == mcu_boot_flash_handle) {
mender_log_error("Set pending image requested but handle is cleared");
return MENDER_FAIL;
Expand All @@ -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_has_payload = false;
return MENDER_OK;
}

Expand Down

0 comments on commit fbf1f55

Please sign in to comment.