diff options
author | Pierre Grandin <grandinp@altern.org> | 2017-01-23 13:53:47 -0800 |
---|---|---|
committer | Pierre Grandin <grandinp@altern.org> | 2017-01-23 13:53:47 -0800 |
commit | 89beb5ad89255360ef5cb2d1b7cbea863af4020b (patch) | |
tree | a2c87ebc6a48e2a51b340ecbb18e91140cf8a75f | |
parent | f763899301e297ea3a0ddf5338b1b3506dd72b48 (diff) | |
download | navit-89beb5ad89255360ef5cb2d1b7cbea863af4020b.tar.gz |
Close file descriptor when download is finished
-rw-r--r-- | navit/network.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/navit/network.c b/navit/network.c index 71dfff1e7..426aebd9b 100644 --- a/navit/network.c +++ b/navit/network.c @@ -15,7 +15,6 @@ ultotal, double ulnow) // Could be use to trigger a cancel from the UI } - void * download_map(void * arguments) { struct map_download_info * dl_info = arguments; @@ -27,20 +26,23 @@ void * download_map(void * arguments) handle = curl_easy_init(); curl_easy_setopt(handle, CURLOPT_URL, dl_info->url); + // Map server might redirect to a mirror + curl_easy_setopt(handle, CURLOPT_FOLLOWLOCATION, 1L); curl_easy_setopt(handle, CURLOPT_PROGRESSDATA, dl_info); curl_easy_setopt(handle, CURLOPT_NOPROGRESS, 0); curl_easy_setopt(handle, CURLOPT_PROGRESSFUNCTION, progressCallBack); FILE* file = fopen( "out.bin", "w"); - curl_easy_setopt( handle, CURLOPT_WRITEDATA, file) ; - curl_easy_perform( handle ); + res = curl_easy_perform( handle ); + fclose(file); if(res != CURLE_OK) - fprintf(stderr, "%s\n", curl_easy_strerror(res)); + dbg(lvl_error, "%s\n", curl_easy_strerror(res)); curl_easy_cleanup(handle); + dbg(lvl_error, "download complete\n"); dl_info->downloading = 0; return (int)res;; |