]> git.saurik.com Git - apt.git/blobdiff - methods/gzip.cc
support running "--simulate" as user
[apt.git] / methods / gzip.cc
index 75a0389793512ba433d1fd88ff343c5ebbc4f9c7..f732c0b8600f227bd98e0fb088038aea4383e8c8 100644 (file)
@@ -52,12 +52,19 @@ bool GzipMethod::Fetch(FetchItem *Itm)
    // Open the source and destination files
    FileFd From(Path,FileFd::ReadOnly);
 
+   // if the file is empty, just rename it and return
+   if(From.Size() == 0) 
+   {
+      rename(Path.c_str(), Itm->DestFile.c_str());
+      return true;
+   }
+
    int GzOut[2];   
    if (pipe(GzOut) < 0)
       return _error->Errno("pipe",_("Couldn't open pipe for %s"),Prog);
 
    // Fork gzip
-   int Process = ExecFork();
+   pid_t Process = ExecFork();
    if (Process == 0)
    {
       close(GzOut[0]);
@@ -111,6 +118,7 @@ bool GzipMethod::Fetch(FetchItem *Itm)
       if (To.Write(Buffer,Count) == false)
       {
         Failed = true;
+        FromGz.Close();
         break;
       }      
    }