+static void load_url_result_cleanup_local(struct load_url_result *result)
+{
+ if (result->cleanup_local)
+ unlink(result->local);
+}
+
+static void load_url_process_exit(struct process *process)
+{
+ struct load_task *task = process->data;
+ struct load_url_result *result;
+ load_url_complete cb;
+ void *data;
+
+ pb_debug("The download client '%s' [pid %d, url %s] exited, rc %d\n",
+ process->path, process->pid, task->url->full,
+ process->exit_status);
+
+ result = task->result;
+ data = task->async_data;
+ cb = task->async_cb;
+
+ if (result->status == LOAD_CANCELLED) {
+ load_url_result_cleanup_local(result);
+ } else if (process_exit_ok(process)) {
+ result->status = LOAD_OK;
+ } else {
+ result->status = LOAD_ERROR;
+ load_url_result_cleanup_local(result);
+ pb_debug("Download client stdout buffer:\n%s\n",
+ process->stdout_buf);
+ }
+
+ if (result->status == LOAD_OK && process->stdout_data)
+ device_handler_status_info(process->stdout_data,
+ _("Download complete: %s"), task->url->file);
+
+ /* The load callback may well free the ctx, which was the
+ * talloc parent of the task. Therefore, we want to do our cleanup
+ * before invoking it
+ */
+ process_release(process);
+ talloc_free(task);
+ result->task = NULL;
+
+ cb(result, data);
+}
+
+/*
+ * Callback to retrieve progress information from Busybox utilities.
+ * Busybox utilities use a common progress bar format which progress percentage
+ * and current size can be can be parsed from.