summaryrefslogtreecommitdiff
path: root/methods
diff options
context:
space:
mode:
Diffstat (limited to 'methods')
-rw-r--r--methods/copy.cc14
-rw-r--r--methods/server.cc7
-rw-r--r--methods/server.h2
3 files changed, 16 insertions, 7 deletions
diff --git a/methods/copy.cc b/methods/copy.cc
index 8c797ff1f..30a3f4a51 100644
--- a/methods/copy.cc
+++ b/methods/copy.cc
@@ -32,7 +32,7 @@ class CopyMethod : public pkgAcqMethod
public:
- CopyMethod() : pkgAcqMethod("1.0",SingleInstance|SendConfig) {};
+ CopyMethod() : pkgAcqMethod("1.0",SingleInstance | SendConfig) {};
};
void CopyMethod::CalculateHashes(FetchResult &Res)
@@ -55,8 +55,8 @@ void CopyMethod::CalculateHashes(FetchResult &Res)
/* */
bool CopyMethod::Fetch(FetchItem *Itm)
{
- URI Get = Itm->Uri;
- std::string File = Get.Path;
+ // this ensures that relative paths work in copy
+ std::string File = Itm->Uri.substr(Itm->Uri.find(':')+1);
// Stat the file and send a start message
struct stat Buf;
@@ -79,6 +79,14 @@ bool CopyMethod::Fetch(FetchItem *Itm)
return true;
}
+ // just calc the hashes if the source and destination are identical
+ if (File == Itm->DestFile)
+ {
+ CalculateHashes(Res);
+ URIDone(Res);
+ return true;
+ }
+
// See if the file exists
FileFd From(File,FileFd::ReadOnly);
FileFd To(Itm->DestFile,FileFd::WriteAtomic);
diff --git a/methods/server.cc b/methods/server.cc
index c91d3b218..ff67eb09b 100644
--- a/methods/server.cc
+++ b/methods/server.cc
@@ -44,7 +44,8 @@ time_t ServerMethod::FailTime = 0;
// ---------------------------------------------------------------------
/* Returns 0 if things are OK, 1 if an IO error occurred and 2 if a header
parse error occurred */
-ServerState::RunHeadersResult ServerState::RunHeaders(FileFd * const File)
+ServerState::RunHeadersResult ServerState::RunHeaders(FileFd * const File,
+ const std::string &Uri)
{
State = Header;
@@ -66,7 +67,7 @@ ServerState::RunHeadersResult ServerState::RunHeaders(FileFd * const File)
continue;
if (Owner->Debug == true)
- clog << Data;
+ clog << "Answer for: " << Uri << endl << Data;
for (string::const_iterator I = Data.begin(); I < Data.end(); ++I)
{
@@ -485,7 +486,7 @@ int ServerMethod::Loop()
Fetch(0);
// Fetch the next URL header data from the server.
- switch (Server->RunHeaders(File))
+ switch (Server->RunHeaders(File, Queue->Uri))
{
case ServerState::RUN_HEADERS_OK:
break;
diff --git a/methods/server.h b/methods/server.h
index 5299b3954..aa692ea93 100644
--- a/methods/server.h
+++ b/methods/server.h
@@ -68,7 +68,7 @@ struct ServerState
RUN_HEADERS_PARSE_ERROR
};
/** \brief Get the headers before the data */
- RunHeadersResult RunHeaders(FileFd * const File);
+ RunHeadersResult RunHeaders(FileFd * const File, const std::string &Uri);
bool Comp(URI Other) const {return Other.Host == ServerName.Host && Other.Port == ServerName.Port;};
virtual void Reset() {Major = 0; Minor = 0; Result = 0; Code[0] = '\0'; Size = 0;