X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/caffd4807f612e931ecca8f7d9b0c0c10de27ce6..468720c59fcf48b20332cdb7b601b2b0d7cbbfbb:/methods/rred.cc diff --git a/methods/rred.cc b/methods/rred.cc index 1a18a381c..56ad8220b 100644 --- a/methods/rred.cc +++ b/methods/rred.cc @@ -1,10 +1,13 @@ // Includes /*{{{*/ +#include + #include #include #include #include #include #include +#include #include #include @@ -51,7 +54,7 @@ protected: virtual bool Fetch(FetchItem *Itm); public: - RredMethod() : pkgAcqMethod("1.1",SingleInstance | SendConfig) {}; + RredMethod() : pkgAcqMethod("1.1",SingleInstance | SendConfig), Debug(false) {}; }; /*}}}*/ /** \brief applyFile - in reverse order with a tail recursion {{{ @@ -239,7 +242,9 @@ RredMethod::State RredMethod::patchFile(FileFd &Patch, FileFd &From, /*{{{*/ return result; } /*}}}*/ -struct EdCommand { /*{{{*/ +/* struct EdCommand {{{*/ +#ifdef _POSIX_MAPPED_FILES +struct EdCommand { size_t data_start; size_t data_end; size_t data_lines; @@ -248,17 +253,25 @@ struct EdCommand { /*{{{*/ char type; }; #define IOV_COUNT 1024 /* Don't really want IOV_MAX since it can be arbitrarily large */ +#endif /*}}}*/ RredMethod::State RredMethod::patchMMap(FileFd &Patch, FileFd &From, /*{{{*/ FileFd &out_file, Hashes *hash) const { #ifdef _POSIX_MAPPED_FILES - MMap ed_cmds(Patch, MMap::ReadOnly); + MMap ed_cmds(MMap::ReadOnly); if (Patch.gzFd() != NULL) { - unsigned long mapSize = Patch.Size(); - DynamicMMap dyn(0, mapSize, 0); - gzread(Patch.gzFd(), dyn.Data(), mapSize); - ed_cmds = dyn; - } + unsigned long long mapSize = Patch.Size(); + DynamicMMap* dyn = new DynamicMMap(0, mapSize, 0); + if (dyn->validData() == false) { + delete dyn; + return MMAP_FAILED; + } + dyn->AddSize(mapSize); + gzread(Patch.gzFd(), dyn->Data(), mapSize); + ed_cmds = *dyn; + } else + ed_cmds = MMap(Patch, MMap::ReadOnly); + MMap in_file(From, MMap::ReadOnly); if (ed_cmds.Size() == 0 || in_file.Size() == 0) @@ -460,7 +473,7 @@ bool RredMethod::Fetch(FetchItem *Itm) /*{{{*/ { Debug = _config->FindB("Debug::pkgAcquire::RRed", false); URI Get = Itm->Uri; - string Path = Get.Host + Get.Path; // To account for relative paths + std::string Path = Get.Host + Get.Path; // To account for relative paths FetchResult Res; Res.Filename = Itm->DestFile; @@ -476,7 +489,7 @@ bool RredMethod::Fetch(FetchItem *Itm) /*{{{*/ // Open the source and destination files (the d'tor of FileFd will do // the cleanup/closing of the fds) FileFd From(Path,FileFd::ReadOnly); - FileFd Patch(Path+".ed",FileFd::ReadOnlyGzip); + FileFd Patch(Path+".ed",FileFd::ReadOnly, FileFd::Gzip); FileFd To(Itm->DestFile,FileFd::WriteAtomic); To.EraseOnFailure(); if (_error->PendingError() == true) @@ -513,7 +526,7 @@ bool RredMethod::Fetch(FetchItem *Itm) /*{{{*/ and use the access time from the "old" file */ struct stat BufBase, BufPatch; if (stat(Path.c_str(),&BufBase) != 0 || - stat(string(Path+".ed").c_str(),&BufPatch) != 0) + stat(std::string(Path+".ed").c_str(),&BufPatch) != 0) return _error->Errno("stat",_("Failed to stat")); struct utimbuf TimeBuf;