about summary refs log tree commit diff stats
path: root/tests/unittests/tools
diff options
context:
space:
mode:
authorIsaacM88 <izack23@gmail.com>2023-03-09 13:16:42 -0700
committerIsaacM88 <izack23@gmail.com>2023-03-09 15:02:26 -0700
commitd043d53948284ab7d1f3ae92c891703033cc98b1 (patch)
tree498b87e4012f5ae1f1a4b7ea1f5770ef26f889c2 /tests/unittests/tools
parent4887d21a119ed67756a1544ec953aa010257bcb1 (diff)
downloadprofani-tty-d043d53948284ab7d1f3ae92c891703033cc98b1.tar.gz
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.
Diffstat (limited to 'tests/unittests/tools')
-rw-r--r--tests/unittests/tools/stub_aesgcm_download.c1
-rw-r--r--tests/unittests/tools/stub_http_download.c1
2 files changed, 2 insertions, 0 deletions
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;