]> git.saurik.com Git - apt.git/commitdiff
* Reset curl options and timestamp between downloaded files. Thanks to
authorOtavio Salvador <otavio@debian.org>
Fri, 10 Aug 2007 21:05:05 +0000 (18:05 -0300)
committerOtavio Salvador <otavio@debian.org>
Fri, 10 Aug 2007 21:05:05 +0000 (18:05 -0300)
  Ryan Murray <rmurray@debian.org> for the patch (closes: #437150)

debian/changelog
methods/https.cc

index c4b893fce73538c91ef0215e06c56c027ae2f653..f8d6ae6d8b56a0cfe7cecd81396a3c1d58839168 100644 (file)
@@ -25,6 +25,8 @@ apt (0.7.7) UNRELEASED; urgency=low
   [ Otavio Salvador ]
   * Add hash support to copy method. Thanks Anders Kaseorg by the patch
     (closes: #436055)
+  * Reset curl options and timestamp between downloaded files. Thanks to
+    Ryan Murray <rmurray@debian.org> for the patch (closes: #437150)
 
  -- Otavio Salvador <otavio@debian.org>  Mon, 06 Aug 2007 10:44:53 -0300
 
index e6717e63ae3f9b6aa4513508aca04b2a3571787a..3b2b0bb19e3dfb8c2ac6139ee0955f1a54fc5fc9 100644 (file)
@@ -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)