Skip to content

Commit

Permalink
Merge pull request #160 from UVV-gh/bugfix/download-only-response
Browse files Browse the repository at this point in the history
Bugfix/download only response
  • Loading branch information
Bastian-Krause authored Jul 17, 2023
2 parents c5e2091 + ad332dc commit 191bd51
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/hawkbit-client.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
13 changes: 13 additions & 0 deletions src/hawkbit-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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("");
Expand Down Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion test/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']

0 comments on commit 191bd51

Please sign in to comment.