diff --git a/main.c b/main.c index bac19f6..4ac1aec 100644 --- a/main.c +++ b/main.c @@ -401,6 +401,11 @@ void parse_config (void) { tasprintf (&secret_chat_file_name, "%s/%s/%s", get_home_directory (), CONFIG_DIRECTORY, SECRET_CHAT_FILE); } tgl_set_download_directory (downloads_directory); + if (!mkdir (downloads_directory, CONFIG_DIRECTORY_MODE)) { + if (!disable_output) { + printf ("[%s] created\n", downloads_directory); + } + } } #endif diff --git a/queries.c b/queries.c index ec210a0..eb2779e 100644 --- a/queries.c +++ b/queries.c @@ -2415,6 +2415,10 @@ static int download_on_answer (struct query *q) { struct download *D = q->extra; if (D->fd == -1) { D->fd = open (D->name, O_CREAT | O_WRONLY, 0640); + if (D->fd < 0) { + vlogprintf (E_ERROR, "Can not open for writing: %m\n"); + assert (D->fd >= 0); + } } fetch_int (); // mtime int len = prefetch_strlen ();