X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Flib%2Finternet.cc;h=7bc818717a44737f2719960a8bc8832aff4eec82;hp=c28e650fdd92f4514bb850dacd13c7869b040ad4;hb=aeb835a18c8df347e0ed68fb24631b320abeb611;hpb=9a2b45caa81d8fb056802dfe3c25f214e808ffdf diff --git a/src/lib/internet.cc b/src/lib/internet.cc index c28e650fd..7bc818717 100644 --- a/src/lib/internet.cc +++ b/src/lib/internet.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington + Copyright (C) 2014-2015 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,9 +21,11 @@ #include #include #include +#include #include #include -#include "util.h" +#include "scoped_temporary.h" +#include "compose.hpp" #include "safe_stringstream.h" #include "i18n.h" @@ -32,6 +34,7 @@ using std::string; using std::list; using boost::optional; using boost::function; +using boost::algorithm::trim; static size_t get_from_zip_url_data (void* buffer, size_t size, size_t nmemb, void* stream) @@ -50,12 +53,14 @@ get_from_zip_url (string url, string file, function (_("Could not open downloaded ZIP file")); } - + struct zip_file* zip_file = zip_fopen (zip, file.c_str(), 0); if (!zip_file) { return optional (_("Unexpected ZIP file contents")); } - + ScopedTemporary temp_cert; f = temp_cert.open ("wb"); char buffer[4096]; @@ -88,7 +93,7 @@ get_from_zip_url (string url, string file, function (); } @@ -117,6 +122,8 @@ ftp_ls (string url) url += "/"; } curl_easy_setopt (curl, CURLOPT_URL, url.c_str ()); + /* 20s timeout */ + curl_easy_setopt (curl, CURLOPT_TIMEOUT, 20); string ls_raw; struct curl_slist* commands = 0; @@ -133,7 +140,8 @@ ftp_ls (string url) SafeStringStream s (ls_raw); list ls; while (s.good ()) { - string const line = s.getline (); + string line = s.getline (); + trim (line); if (line.length() > 55) { string const file = line.substr (55); if (file != "." && file != "..") {