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

@@ -1680,9 +1680,9 @@ win_appendln_highlight(ProfWin* window, theme_item_t theme_item, const char* con
}
void
win_print_http_transfer(ProfWin* window, const char* const message, char* url)
win_print_http_transfer(ProfWin* window, const char* const message, char* id)
{
win_print_outgoing_with_receipt(window, "!", NULL, message, url, NULL);
win_print_outgoing_with_receipt(window, "!", NULL, message, id, NULL);
}
void

View File

@@ -74,7 +74,7 @@ void win_print_outgoing_muc_msg(ProfWin* window, char* show_char, const char* co
void win_print_history(ProfWin* window, const ProfMessage* const message);
void win_print_old_history(ProfWin* window, const ProfMessage* const message);
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_newline(ProfWin* window);
void win_redraw(ProfWin* window);