X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/22041bd2864b8d0b401b45dde9eda4003a11fec4..40468850491c4f5bc7060763a6f03cdc570d514e:/methods/gzip.cc diff --git a/methods/gzip.cc b/methods/gzip.cc index 5b9b66b50..6ab6548ef 100644 --- a/methods/gzip.cc +++ b/methods/gzip.cc @@ -9,6 +9,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include @@ -39,21 +41,17 @@ class GzipMethod : public pkgAcqMethod bool GzipMethod::Fetch(FetchItem *Itm) { 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; URIStart(Res); // Open the source and destination files - FileFd From(Path,FileFd::ReadOnlyGzip); + FileFd From(Path,FileFd::ReadOnly, FileFd::Gzip); - // if the file is empty, just rename it and return - if(From.Size() == 0) - { - rename(Path.c_str(), Itm->DestFile.c_str()); - return true; - } + if(From.FileSize() == 0) + return _error->Error(_("Empty files can't be valid archives")); FileFd To(Itm->DestFile,FileFd::WriteAtomic); To.EraseOnFailure(); @@ -66,7 +64,7 @@ bool GzipMethod::Fetch(FetchItem *Itm) while (1) { unsigned char Buffer[4*1024]; - unsigned long Count; + unsigned long long Count = 0; if (!From.Read(Buffer,sizeof(Buffer),&Count)) {