diff --git a/include/hawkbit-client.h b/include/hawkbit-client.h index 91e33e32..200c8df6 100644 --- a/include/hawkbit-client.h +++ b/include/hawkbit-client.h @@ -90,6 +90,7 @@ typedef struct Artifact_ { gchar *download_url; /**< download URL of software bundle file */ gchar *feedback_url; /**< URL status feedback should be sent to */ gchar *sha1; /**< sha1 checksum of software bundle file */ + gchar *maintenance_window; /**< maintenance flag, possible values: available, unavailable, null */ gboolean do_install; /**< whether the installation should be started or not */ } Artifact; diff --git a/src/hawkbit-client.c b/src/hawkbit-client.c index b7fc162b..ffe932e6 100644 --- a/src/hawkbit-client.c +++ b/src/hawkbit-client.c @@ -914,6 +914,17 @@ static gpointer download_thread(gpointer data) } g_mutex_lock(&active_action->mutex); + // skip installation if hawkBit asked us to do so + if (!artifact->do_install && + (!artifact->maintenance_window || g_strcmp0(artifact->maintenance_window, "available") == 0)) { + active_action->state = ACTION_STATE_SUCCESS; + if (!feedback(artifact->feedback_url, active_action->id, "File checksum OK.", "success", + "downloaded", &feedback_error)) + g_warning("%s", feedback_error->message); + + g_mutex_unlock(&active_action->mutex); + return GINT_TO_POINTER(TRUE); + } if (!feedback_progress(artifact->feedback_url, active_action->id, "File checksum OK.", &error)) { g_warning("%s", error->message); @@ -1064,6 +1075,7 @@ static gboolean process_deployment(JsonNode *req_root, GError **error) // handle deployment.maintenanceWindow (only available if maintenance window is defined) maintenance_window = json_get_string(resp_root, "$.deployment.maintenanceWindow", NULL); + artifact->maintenance_window = g_strdup(maintenance_window); maintenance_msg = maintenance_window ? g_strdup_printf(" (maintenance window is '%s')", maintenance_window) : g_strdup(""); @@ -1486,6 +1498,7 @@ void artifact_free(Artifact *artifact) g_free(artifact->download_url); g_free(artifact->feedback_url); g_free(artifact->sha1); + g_free(artifact->maintenance_window); g_free(artifact); } diff --git a/test/test_download.py b/test/test_download.py index 697ed143..71c80e5c 100644 --- a/test/test_download.py +++ b/test/test_download.py @@ -137,7 +137,7 @@ def test_download_only(hawkbit, config, assign_bundle): assert exitcode == 0 status = hawkbit.get_action_status() - assert any(['download' in s['type'] for s in status]) + assert status[0]['type'] == 'downloaded' # check last status message assert 'File checksum OK.' in status[0]['messages']