X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/bfd22fc0ac2632c6196f5149dc3b3671d9ff15e0..aee86e6efa7947f2985140732a63e605704c9aa9:/methods/gzip.cc diff --git a/methods/gzip.cc b/methods/gzip.cc index a78fcb3ee..337219316 100644 --- a/methods/gzip.cc +++ b/methods/gzip.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: gzip.cc,v 1.5 1998/11/05 07:21:47 jgg Exp $ +// $Id: gzip.cc,v 1.9 1999/12/10 23:40:29 jgg Exp $ /* ###################################################################### GZip method - Take a file URI in and decompress it into the target @@ -12,12 +12,11 @@ #include #include #include -#include +#include #include #include #include -#include #include /*}}}*/ @@ -37,6 +36,10 @@ bool GzipMethod::Fetch(FetchItem *Itm) { URI Get = Itm->Uri; + FetchResult Res; + Res.Filename = Itm->DestFile; + URIStart(Res); + // Open the source and destintation files FileFd From(Get.Path,FileFd::ReadOnly); FileFd To(Itm->DestFile,FileFd::WriteEmpty); @@ -69,19 +72,12 @@ bool GzipMethod::Fetch(FetchItem *Itm) From.Close(); // Wait for gzip to finish - int Status; - if (waitpid(Process,&Status,0) != Process) - { - To.OpFail(); - return _error->Errno("wait","Waiting for gzip failed"); - } - - if (WIFEXITED(Status) == 0 || WEXITSTATUS(Status) != 0) + if (ExecWait(Process,_config->Find("Dir::bin::gzip","gzip").c_str(),false) == false) { To.OpFail(); - return _error->Error("gzip failed, perhaps the disk is full or the directory permissions are wrong."); - } - + return false; + } + To.Close(); // Transfer the modification times @@ -95,10 +91,12 @@ bool GzipMethod::Fetch(FetchItem *Itm) if (utime(Itm->DestFile.c_str(),&TimeBuf) != 0) return _error->Errno("utime","Failed to set modification time"); + if (stat(Itm->DestFile.c_str(),&Buf) != 0) + return _error->Errno("stat","Failed to stat"); + // Return a Done response - FetchResult Res; Res.LastModified = Buf.st_mtime; - Res.Filename = Itm->DestFile; + Res.Size = Buf.st_size; URIDone(Res); return true;