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.
This commit is contained in:
IsaacM88
2023-03-09 13:16:42 -07:00
parent 4887d21a11
commit d043d53948
12 changed files with 43 additions and 28 deletions

View File

@@ -45,7 +45,7 @@
#define FALLBACK_MSG ""
void
http_print_transfer_update(ProfWin* window, char* url, const char* fmt, ...)
http_print_transfer_update(ProfWin* window, char* id, const char* fmt, ...)
{
va_list args;
@@ -54,13 +54,13 @@ http_print_transfer_update(ProfWin* window, char* url, const char* fmt, ...)
g_string_vprintf(msg, fmt, args);
va_end(args);
win_update_entry_message(window, url, msg->str);
win_update_entry_message(window, id, msg->str);
g_string_free(msg, TRUE);
}
void
http_print_transfer(ProfWin* window, char* url, const char* fmt, ...)
http_print_transfer(ProfWin* window, char* id, const char* fmt, ...)
{
va_list args;
@@ -69,7 +69,7 @@ http_print_transfer(ProfWin* window, char* url, const char* fmt, ...)
g_string_vprintf(msg, fmt, args);
va_end(args);
win_print_http_transfer(window, msg->str, url);
win_print_http_transfer(window, msg->str, id);
g_string_free(msg, TRUE);
}