From ded14999815cc2dea0fe1916ceacc307ea339d40 Mon Sep 17 00:00:00 2001 From: Otavio Salvador Date: Mon, 6 Aug 2007 10:45:59 -0300 Subject: * Add hash support to copy method. Thanks Anders Kaseorg by the patch (closes: #436055) --- methods/copy.cc | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'methods') diff --git a/methods/copy.cc b/methods/copy.cc index d737e3c33..72896b4c0 100644 --- a/methods/copy.cc +++ b/methods/copy.cc @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -79,6 +80,10 @@ bool CopyMethod::Fetch(FetchItem *Itm) return _error->Errno("utime",_("Failed to set modification time")); } + Hashes Hash; + FileFd Fd(Res.Filename, FileFd::ReadOnly); + Hash.AddFD(Fd.Fd(), Fd.Size()); + Res.TakeHashes(Hash); URIDone(Res); return true; } -- cgit v1.2.3-70-g09d2 From 5820530d3d12e509229fd624b8bb166728e6a21a Mon Sep 17 00:00:00 2001 From: Otavio Salvador Date: Fri, 10 Aug 2007 18:05:05 -0300 Subject: * Reset curl options and timestamp between downloaded files. Thanks to Ryan Murray for the patch (closes: #437150) --- debian/changelog | 2 ++ methods/https.cc | 13 +++++++++++++ 2 files changed, 15 insertions(+) (limited to 'methods') diff --git a/debian/changelog b/debian/changelog index c4b893fce..f8d6ae6d8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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 for the patch (closes: #437150) -- Otavio Salvador Mon, 06 Aug 2007 10:44:53 -0300 diff --git a/methods/https.cc b/methods/https.cc index e6717e63a..3b2b0bb19 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) -- cgit v1.2.3-70-g09d2 From 31c64df39bad4c709a2fd5ca6a336f4b652a8613 Mon Sep 17 00:00:00 2001 From: Otavio Salvador Date: Tue, 2 Oct 2007 09:35:23 -0300 Subject: - methods/gpgv.cc: conversion from string constant to 'char*'; --- debian/changelog | 1 + methods/gpgv.cc | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'methods') diff --git a/debian/changelog b/debian/changelog index 592fbe14d..b8e9889b8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -63,6 +63,7 @@ apt (0.7.7) UNRELEASED; urgency=low has type 'size_t'; - apt-pkg/deb/dpkgpm.cc: initialization order and conversion from string constant to 'char*'; + - methods/gpgv.cc: conversion from string constant to 'char*'; [ Ian Jackson ] * dpkg-triggers: Deal properly with new package states. diff --git a/methods/gpgv.cc b/methods/gpgv.cc index 227e08d63..2b1fa5169 100644 --- a/methods/gpgv.cc +++ b/methods/gpgv.cc @@ -121,9 +121,9 @@ string GPGVMethod::VerifyGetSigners(const char *file, const char *outfile, // Redirect the pipe to the status fd (3) dup2(fd[1], 3); - putenv("LANG="); - putenv("LC_ALL="); - putenv("LC_MESSAGES="); + putenv((char *)"LANG="); + putenv((char *)"LC_ALL="); + putenv((char *)"LC_MESSAGES="); execvp(gpgvpath.c_str(), (char **)Args); exit(111); -- cgit v1.2.3-70-g09d2 From b856433668b3ffeab82ae2712f2e672a5dca1396 Mon Sep 17 00:00:00 2001 From: Otavio Salvador Date: Tue, 2 Oct 2007 09:36:42 -0300 Subject: - methods/ftp.cc: likewise; --- debian/changelog | 1 + methods/ftp.cc | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'methods') diff --git a/debian/changelog b/debian/changelog index b8e9889b8..802f6f4d9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -64,6 +64,7 @@ apt (0.7.7) UNRELEASED; urgency=low - apt-pkg/deb/dpkgpm.cc: initialization order and conversion from string constant to 'char*'; - methods/gpgv.cc: conversion from string constant to 'char*'; + - methods/ftp.cc: likewise; [ Ian Jackson ] * dpkg-triggers: Deal properly with new package states. diff --git a/methods/ftp.cc b/methods/ftp.cc index 0c2aa00a7..554a24cf5 100644 --- a/methods/ftp.cc +++ b/methods/ftp.cc @@ -1101,7 +1101,7 @@ int main(int argc,const char *argv[]) char S[300]; snprintf(S,sizeof(S),"http_proxy=%s",getenv("ftp_proxy")); putenv(S); - putenv("no_proxy="); + putenv((char *)"no_proxy="); // Run the http method string Path = flNotFile(argv[0]) + "http"; -- cgit v1.2.3-70-g09d2 From d6039f9e73d440f1e49ac880f5017cb6aaf4546e Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 5 Oct 2007 07:48:13 +0200 Subject: methods/https.cc: - delete zero size I-M-S hits - fix of-by-one error in I-M-S code --- debian/changelog | 3 ++- methods/https.cc | 26 +++++++++++++------------- 2 files changed, 15 insertions(+), 14 deletions(-) (limited to 'methods') diff --git a/debian/changelog b/debian/changelog index 7687fce5a..d43fb9861 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,9 +7,10 @@ apt (0.7.7) UNRELEASED; urgency=low * apt-pkg/acquire-item.cc: - remove zero size files on I-M-S hit * methods/https.cc: - - only send LastModified if we actually have one + - only send LastModified if we actually have a file - send range request with if-range - delete failed downloads + - delete zero size I-M-S hits * apt-pkg/deb/dpkgpm.{cc,h}: - merged dpkg-log branch, this lets you specify a Dir::Log::Terminal file to log dpkg output to diff --git a/methods/https.cc b/methods/https.cc index 3b2b0bb19..b2bbbddb1 100644 --- a/methods/https.cc +++ b/methods/https.cc @@ -161,13 +161,6 @@ bool HttpsMethod::Fetch(FetchItem *Itm) } curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); - // set time values - if(Itm->LastModified > 0) - { - curl_easy_setopt(curl, CURLOPT_TIMECONDITION, CURL_TIMECOND_IFMODSINCE); - curl_easy_setopt(curl, CURLOPT_TIMEVALUE, Itm->LastModified); - } - // speed limit int dlLimit = _config->FindI("Acquire::http::Dl-Limit",0)*1024; if (dlLimit > 0) @@ -183,7 +176,7 @@ bool HttpsMethod::Fetch(FetchItem *Itm) // error handling curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, curl_errorstr); - // In this case we send an if-range query with a range header + // if we have the file send an if-range query with a range header if (stat(Itm->DestFile.c_str(),&SBuf) >= 0 && SBuf.st_size > 0) { char Buf[1000]; @@ -191,11 +184,17 @@ bool HttpsMethod::Fetch(FetchItem *Itm) (long)SBuf.st_size - 1, TimeRFC1123(SBuf.st_mtime).c_str()); headers = curl_slist_append(headers, Buf); + } + else if(Itm->LastModified > 0) + { + curl_easy_setopt(curl, CURLOPT_TIMECONDITION, CURL_TIMECOND_IFMODSINCE); + curl_easy_setopt(curl, CURLOPT_TIMEVALUE, Itm->LastModified); } // go for it - if the file exists, append on it File = new FileFd(Itm->DestFile, FileFd::WriteAny); - File->Seek(File->Size()); + if (File->Size() > 0) + File->Seek(File->Size() - 1); // keep apt updated Res.Filename = Itm->DestFile; @@ -217,9 +216,6 @@ bool HttpsMethod::Fetch(FetchItem *Itm) } File->Close(); - if (Res.Size == 0) - Res.Size = File->Size(); - // Timestamp struct utimbuf UBuf; if (curl_servdate != -1) { @@ -232,15 +228,19 @@ bool HttpsMethod::Fetch(FetchItem *Itm) struct stat Buf; if (stat(File->Name().c_str(),&Buf) == 0) { - Res.Size = Buf.st_size; Res.Filename = File->Name(); Res.LastModified = Buf.st_mtime; Res.IMSHit = false; if (curl_responsecode == 304) { + unlink(File->Name().c_str()); Res.IMSHit = true; Res.LastModified = Itm->LastModified; + Res.Size = 0; + URIDone(Res); + return true; } + Res.Size = Buf.st_size; } // take hashes -- cgit v1.2.3-70-g09d2 From f6fa4a10db080c33df1361f092f3e0ddb33ac3b9 Mon Sep 17 00:00:00 2001 From: Otavio Salvador Date: Thu, 25 Oct 2007 10:03:35 -0200 Subject: Changed ABI --- apt-pkg/init.h | 2 +- apt-pkg/makefile | 2 +- methods/makefile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'methods') diff --git a/apt-pkg/init.h b/apt-pkg/init.h index 23e951eff..6d8693be9 100644 --- a/apt-pkg/init.h +++ b/apt-pkg/init.h @@ -18,7 +18,7 @@ // See the makefile #define APT_PKG_MAJOR 4 -#define APT_PKG_MINOR 5 +#define APT_PKG_MINOR 6 #define APT_PKG_RELEASE 0 extern const char *pkgVersion; diff --git a/apt-pkg/makefile b/apt-pkg/makefile index b327dbf64..1b78c94f6 100644 --- a/apt-pkg/makefile +++ b/apt-pkg/makefile @@ -13,7 +13,7 @@ include ../buildlib/defaults.mak # methods/makefile - FIXME LIBRARY=apt-pkg LIBEXT=$(GLIBC_VER)$(LIBSTDCPP_VER) -MAJOR=4.5 +MAJOR=4.6 MINOR=0 SLIBS=$(PTHREADLIB) $(INTLLIBS) -lutil APT_DOMAIN:=libapt-pkg$(MAJOR) diff --git a/methods/makefile b/methods/makefile index e47539dbb..5794c84e7 100644 --- a/methods/makefile +++ b/methods/makefile @@ -7,7 +7,7 @@ include ../buildlib/defaults.mak BIN := $(BIN)/methods # FIXME.. -LIB_APT_PKG_MAJOR = 4.5 +LIB_APT_PKG_MAJOR = 4.6 APT_DOMAIN := libapt-pkg$(LIB_APT_PKG_MAJOR) # The file method -- cgit v1.2.3-70-g09d2