From d530b4c24fc452efc82be4b7e1ebc536a00c09b7 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 3 Oct 2007 02:21:52 +0200 Subject: [PATCH] * Reset curl options and timestamp between downloaded files. Thanks to Ryan Murray for the patch --- debian/changelog | 2 ++ methods/https.cc | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/debian/changelog b/debian/changelog index 87b9dd02..375a6bb1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -6,6 +6,8 @@ apt (0.7.6ubuntu12) gutsy; urgency=low (thanks to Laurent Bigonville, LP: #140019) * apt-pkg/deb/debmetaindex.cc: comparison with string literal results in unspecified behaviour; + * Reset curl options and timestamp between downloaded files. Thanks to + Ryan Murray for the patch [Paul Sladen] * Have 'cron.daily/apt' send D-Bus doesn't exist error messages diff --git a/methods/https.cc b/methods/https.cc index e6717e63..3b2b0bb1 100644 --- a/methods/https.cc +++ b/methods/https.cc @@ -115,6 +115,7 @@ bool HttpsMethod::Fetch(FetchItem *Itm) // - error checking/reporting // - more debug options? (CURLOPT_DEBUGFUNCTION?) + curl_easy_reset(curl); SetupProxy(); // callbacks @@ -125,6 +126,7 @@ bool HttpsMethod::Fetch(FetchItem *Itm) curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, this); curl_easy_setopt(curl, CURLOPT_NOPROGRESS, false); curl_easy_setopt(curl, CURLOPT_FAILONERROR, true); + curl_easy_setopt(curl, CURLOPT_FILETIME, true); // FIXME: https: offer various options of verification bool peer_verify = _config->FindB("Acquire::https::Verify-Peer", false); @@ -202,6 +204,9 @@ bool HttpsMethod::Fetch(FetchItem *Itm) CURLcode success = curl_easy_perform(curl); curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &curl_responsecode); + long curl_servdate; + curl_easy_getinfo(curl, CURLINFO_FILETIME, &curl_servdate); + // cleanup if(success != 0) { @@ -215,6 +220,14 @@ bool HttpsMethod::Fetch(FetchItem *Itm) if (Res.Size == 0) Res.Size = File->Size(); + // Timestamp + struct utimbuf UBuf; + if (curl_servdate != -1) { + UBuf.actime = curl_servdate; + UBuf.modtime = curl_servdate; + utime(File->Name().c_str(),&UBuf); + } + // check the downloaded result struct stat Buf; if (stat(File->Name().c_str(),&Buf) == 0) -- 2.20.1