More detailed ZIP decode errors; fix failure to download some certificates (#1379).
authorCarl Hetherington <cth@carlh.net>
Sun, 14 Oct 2018 14:57:26 +0000 (15:57 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 14 Oct 2018 20:15:05 +0000 (21:15 +0100)
src/lib/internet.cc

index 615ced7892a9037a4509c71fe1d16a94cda1e6be..d1843c460797a874e996797d7adc6666ebefe3c6 100644 (file)
@@ -34,6 +34,7 @@
 
 using std::string;
 using std::list;
+using std::cout;
 using boost::optional;
 using boost::function;
 using boost::algorithm::trim;
@@ -52,7 +53,7 @@ get_from_url (string url, bool pasv, ScopedTemporary& temp)
        CURL* curl = curl_easy_init ();
        curl_easy_setopt (curl, CURLOPT_URL, url.c_str());
 
-       FILE* f = temp.open ("w");
+       FILE* f = temp.open ("wb");
        curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, get_from_url_data);
        curl_easy_setopt (curl, CURLOPT_WRITEDATA, f);
        curl_easy_setopt (curl, CURLOPT_FTP_USE_EPSV, 0);
@@ -120,9 +121,10 @@ get_from_zip_url (string url, string file, bool pasv, function<void (boost::file
        }
 
        zip_error_t error;
+       zip_error_init (&error);
        zip_t* zip = zip_open_from_source (zip_source, ZIP_RDONLY, &error);
        if (!zip) {
-               return String::compose (_("Could not open downloaded ZIP file (%1: %2)"), error.sys_err, error.str ? error.str : "");
+               return String::compose (_("Could not open downloaded ZIP file (%1:%2: %3)"), error.zip_err, error.sys_err, error.str ? error.str : "");
        }
 
 #else