1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-09-15 19:38:07 -04:00
profanity/tests/unittests/tools/stub_http_download.c
IsaacM88 d043d53948 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.
2023-03-09 15:02:26 -07:00

32 lines
518 B
C

#ifndef TOOLS_HTTP_DOWNLOAD_H
#define TOOLS_HTTP_DOWNLOAD_H
#include <curl/curl.h>
#include <pthread.h>
typedef struct prof_win_t ProfWin;
typedef struct http_download_t
{
char* id;
char* url;
char* filename;
char* directory;
FILE* filehandle;
curl_off_t bytes_received;
ProfWin* window;
pthread_t worker;
int cancel;
} HTTPDownload;
void*
http_file_get(void* userdata)
{
return NULL;
}
void http_download_cancel_processes(){};
void http_download_add_download(){};
#endif