summaryrefslogtreecommitdiff
path: root/methods/copy.cc
diff options
context:
space:
mode:
authorMichael Vogt <mvo@ubuntu.com>2014-09-23 15:47:44 +0200
committerMichael Vogt <mvo@ubuntu.com>2014-09-23 15:47:44 +0200
commitdb1d1c32149177c0b6ca49e5107ab1f5fd364660 (patch)
treeb06b22a9c92455b32889c88407f4190113a5cdd9 /methods/copy.cc
parent916b89109cd77728004819d4705778e3dc489b2e (diff)
parentc511c5e8ed3f59ddee1b174b39e5cc16a2f11922 (diff)
Merge remote-tracking branch 'upstream/debian/experimental' into feature/acq-trans
Conflicts: apt-pkg/acquire-item.cc apt-pkg/acquire-item.h methods/copy.cc test/integration/test-hashsum-verification
Diffstat (limited to 'methods/copy.cc')
-rw-r--r--methods/copy.cc14
1 files changed, 11 insertions, 3 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);