diff options
Diffstat (limited to 'src/lib/sync_api_download.c')
-rw-r--r-- | src/lib/sync_api_download.c | 41 |
1 files changed, 13 insertions, 28 deletions
diff --git a/src/lib/sync_api_download.c b/src/lib/sync_api_download.c index 9a7c8f5..7c58957 100644 --- a/src/lib/sync_api_download.c +++ b/src/lib/sync_api_download.c @@ -91,7 +91,8 @@ struct SYNC_DownloadOperation * * @param cls the `struct SYNC_DownloadOperation` * @param response_code HTTP response code, 0 on error - * @param response + * @param data data we downloaded + * @param data_size number of bytes in @a data */ static void handle_download_finished (void *cls, @@ -100,6 +101,9 @@ handle_download_finished (void *cls, size_t data_size) { struct SYNC_DownloadOperation *download = cls; + struct SYNC_DownloadDetails dd = { + .http_status = (unsigned int) response_code + }; download->job = NULL; switch (response_code) @@ -108,7 +112,6 @@ handle_download_finished (void *cls, break; case MHD_HTTP_OK: { - struct SYNC_DownloadDetails dd; struct SYNC_UploadSignaturePS usp = { .purpose.purpose = htonl (TALER_SIGNATURE_SYNC_BACKUP_UPLOAD), .purpose.size = htonl (sizeof (usp)), @@ -125,18 +128,16 @@ handle_download_finished (void *cls, &download->account_pub.eddsa_pub)) { GNUNET_break_op (0); - response_code = 0; + dd.http_status = 0; break; } /* Success, call callback with all details! */ - memset (&dd, 0, sizeof (dd)); - dd.sig = download->account_sig; - dd.prev_backup_hash = download->sync_previous; - dd.curr_backup_hash = usp.new_backup_hash; - dd.backup = data; - dd.backup_size = data_size; + dd.details.ok.sig = download->account_sig; + dd.details.ok.prev_backup_hash = download->sync_previous; + dd.details.ok.curr_backup_hash = usp.new_backup_hash; + dd.details.ok.backup = data; + dd.details.ok.backup_size = data_size; download->cb (download->cb_cls, - response_code, &dd); download->cb = NULL; SYNC_download_cancel (download); @@ -159,14 +160,13 @@ handle_download_finished (void *cls, "Unexpected response code %u\n", (unsigned int) response_code); GNUNET_break (0); - response_code = 0; + dd.http_status = 0; break; } if (NULL != download->cb) { download->cb (download->cb_cls, - response_code, - NULL); + &dd); download->cb = NULL; } SYNC_download_cancel (download); @@ -248,16 +248,6 @@ handle_header (char *buffer, } -/** - * Download the latest version of a backup for account @a pub. - * - * @param ctx for HTTP client request processing - * @param base_url base URL of the Sync server - * @param pub account public key - * @param cb function to call with the backup - * @param cb_cls closure for @a cb - * @return handle for the operation - */ struct SYNC_DownloadOperation * SYNC_download (struct GNUNET_CURL_Context *ctx, const char *base_url, @@ -301,11 +291,6 @@ SYNC_download (struct GNUNET_CURL_Context *ctx, } -/** - * Cancel the download. - * - * @param do operation to cancel. - */ void SYNC_download_cancel (struct SYNC_DownloadOperation *download) { |