From d043d53948284ab7d1f3ae92c891703033cc98b1 Mon Sep 17 00:00:00 2001 From: IsaacM88 Date: Thu, 9 Mar 2023 13:16:42 -0700 Subject: Fix duplicate download IDs. Fixes https://github.com/profanity-im/profanity/issues/1794 Explanation The problem is the download's identifier. Downloads are given an ID so they can be referenced later when their progress changes. Currently, the download's ID is the download's URL. When you download the same file twice, you have two downloads with the same ID. Download progress updates are shown on the first of both downloads with the same ID. Solution Change the download's ID from its URL to a random number. A random ID is generated when get_random_string() is called from cmd_funcs.c. Several other functions are updated to cope with the new ID format. --- tests/unittests/tools/stub_aesgcm_download.c | 1 + tests/unittests/tools/stub_http_download.c | 1 + tests/unittests/ui/stub_ui.c | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/unittests/tools/stub_aesgcm_download.c b/tests/unittests/tools/stub_aesgcm_download.c index 6f4cc0ce..07f411ca 100644 --- a/tests/unittests/tools/stub_aesgcm_download.c +++ b/tests/unittests/tools/stub_aesgcm_download.c @@ -8,6 +8,7 @@ typedef struct http_download_t HTTPDownload; typedef struct aesgcm_download_t { + char* id; char* url; char* filename; ProfWin* window; diff --git a/tests/unittests/tools/stub_http_download.c b/tests/unittests/tools/stub_http_download.c index cc7bddc5..f530b384 100644 --- a/tests/unittests/tools/stub_http_download.c +++ b/tests/unittests/tools/stub_http_download.c @@ -8,6 +8,7 @@ typedef struct prof_win_t ProfWin; typedef struct http_download_t { + char* id; char* url; char* filename; char* directory; diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index d8272aab..edd8c336 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -490,7 +490,7 @@ mucwin_unset_message_char(ProfMucWin* mucwin) void win_update_entry_message(ProfWin* window, const char* const id, const char* const message){}; void win_mark_received(ProfWin* window, const char* const id){}; -void win_print_http_transfer(ProfWin* window, const char* const message, char* url){}; +void win_print_http_transfer(ProfWin* window, const char* const message, char* id){}; void win_print_loading_history(ProfWin* window){}; void -- cgit 1.4.1-2-gfad0