Check return code when downloading files

This commit is contained in:
vvaltman 2014-10-02 23:20:03 +04:00
parent ecdec4620d
commit e5419d2da6
2 changed files with 9 additions and 0 deletions

5
main.c
View File

@ -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

View File

@ -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 ();