mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-21 08:16:21 +00:00
Initial /sendfile OMEMO encryption
This commit is contained in:
@@ -146,7 +146,7 @@ http_file_put(void* userdata)
|
||||
|
||||
pthread_mutex_lock(&lock);
|
||||
char* msg;
|
||||
if (asprintf(&msg, "Uploading '%s': 0%%", upload->filename) == -1) {
|
||||
if (asprintf(&msg, "Uploading '%s': 0%%", upload->filepath) == -1) {
|
||||
msg = strdup(FALLBACK_MSG);
|
||||
}
|
||||
win_print_http_upload(upload->window, msg, upload->put_url);
|
||||
@@ -186,8 +186,8 @@ http_file_put(void* userdata)
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_USERAGENT, "profanity");
|
||||
|
||||
if (!(fd = fopen(upload->filename, "rb"))) {
|
||||
if (asprintf(&err, "failed to open '%s'", upload->filename) == -1) {
|
||||
if (!(fd = fopen(upload->filepath, "rb"))) {
|
||||
if (asprintf(&err, "failed to open '%s'", upload->filepath) == -1) {
|
||||
err = NULL;
|
||||
}
|
||||
goto end;
|
||||
@@ -294,6 +294,7 @@ end:
|
||||
pthread_mutex_unlock(&lock);
|
||||
|
||||
free(upload->filename);
|
||||
free(upload->filepath);
|
||||
free(upload->mime_type);
|
||||
free(upload->get_url);
|
||||
free(upload->put_url);
|
||||
@@ -303,18 +304,18 @@ end:
|
||||
}
|
||||
|
||||
char*
|
||||
file_mime_type(const char* const file_name)
|
||||
file_mime_type(const char* const filepath)
|
||||
{
|
||||
char* out_mime_type;
|
||||
char file_header[FILE_HEADER_BYTES];
|
||||
FILE* fd;
|
||||
if (!(fd = fopen(file_name, "rb"))) {
|
||||
FILE *fd;
|
||||
if (!(fd = fopen(filepath, "rb"))) {
|
||||
return strdup(FALLBACK_MIMETYPE);
|
||||
}
|
||||
size_t file_header_size = fread(file_header, 1, FILE_HEADER_BYTES, fd);
|
||||
fclose(fd);
|
||||
|
||||
char* content_type = g_content_type_guess(file_name, (unsigned char*)file_header, file_header_size, NULL);
|
||||
char *content_type = g_content_type_guess(filepath, (unsigned char*)file_header, file_header_size, NULL);
|
||||
if (content_type != NULL) {
|
||||
char* mime_type = g_content_type_get_mime_type(content_type);
|
||||
out_mime_type = strdup(mime_type);
|
||||
@@ -326,11 +327,10 @@ file_mime_type(const char* const file_name)
|
||||
return out_mime_type;
|
||||
}
|
||||
|
||||
off_t
|
||||
file_size(const char* const filename)
|
||||
off_t file_size(const char* const filepath)
|
||||
{
|
||||
struct stat st;
|
||||
stat(filename, &st);
|
||||
stat(filepath, &st);
|
||||
return st.st_size;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user