X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/b53c9cea2902572822bbbece5bac236c1bbf846e..91414dd77ec7efe1d3fc053e32cbe4d82263e015:/methods/copy.cc diff --git a/methods/copy.cc b/methods/copy.cc index 0c9f322e6..e515b2def 100644 --- a/methods/copy.cc +++ b/methods/copy.cc @@ -17,6 +17,7 @@ #include #include #include +#include "aptmethod.h" #include #include @@ -25,23 +26,14 @@ #include /*}}}*/ -class CopyMethod : public pkgAcqMethod +class CopyMethod : public aptMethod { virtual bool Fetch(FetchItem *Itm) APT_OVERRIDE; - void CalculateHashes(FetchItem const * const Itm, FetchResult &Res); - + public: - - CopyMethod() : pkgAcqMethod("1.0",SingleInstance | SendConfig) {}; -}; -void CopyMethod::CalculateHashes(FetchItem const * const Itm, FetchResult &Res) -{ - Hashes Hash(Itm->ExpectedHashes); - FileFd Fd(Res.Filename, FileFd::ReadOnly, FileFd::Extension); - Hash.AddFD(Fd); - Res.TakeHashes(Hash); -} + CopyMethod() : aptMethod("copy", "1.0",SingleInstance | SendConfig) {}; +}; // CopyMethod::Fetch - Fetch a file /*{{{*/ // --------------------------------------------------------------------- @@ -65,7 +57,7 @@ bool CopyMethod::Fetch(FetchItem *Itm) URIStart(Res); // just calc the hashes if the source and destination are identical - if (File == Itm->DestFile) + if (File == Itm->DestFile || Itm->DestFile == "/dev/null") { CalculateHashes(Itm, Res); URIDone(Res); @@ -76,12 +68,7 @@ bool CopyMethod::Fetch(FetchItem *Itm) FileFd From(File,FileFd::ReadOnly); FileFd To(Itm->DestFile,FileFd::WriteAtomic); To.EraseOnFailure(); - if (_error->PendingError() == true) - { - To.OpFail(); - return false; - } - + // Copy the file if (CopyFile(From,To) == false) { @@ -101,7 +88,6 @@ bool CopyMethod::Fetch(FetchItem *Itm) return _error->Errno("utimes",_("Failed to set modification time")); CalculateHashes(Itm, Res); - URIDone(Res); return true; }