From 8b89e57fa2ae7d34b055b8f804cee0c2c194043b Mon Sep 17 00:00:00 2001 From: Arch Librarian Date: Mon, 20 Sep 2004 16:51:12 +0000 Subject: Stable acquire code Author: jgg Date: 1998-10-26 07:11:43 GMT Stable acquire code --- methods/copy.cc | 3 ++- methods/gzip.cc | 14 +++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'methods') diff --git a/methods/copy.cc b/methods/copy.cc index c1cc26a69..b1c0fe360 100644 --- a/methods/copy.cc +++ b/methods/copy.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: copy.cc,v 1.2 1998/10/25 07:07:29 jgg Exp $ +// $Id: copy.cc,v 1.3 1998/10/26 07:11:52 jgg Exp $ /* ###################################################################### Copy URI - This method takes a uri like a file: uri and copies it @@ -121,6 +121,7 @@ int main() TimeBuf.modtime = Buf.st_mtime; if (utime(Target.c_str(),&TimeBuf) != 0) { + To.OpFail(); _error->Errno("utime","Failed to set modification time"); Fail(URI); continue; diff --git a/methods/gzip.cc b/methods/gzip.cc index 15bff4d83..84ad472e9 100644 --- a/methods/gzip.cc +++ b/methods/gzip.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: gzip.cc,v 1.1 1998/10/25 07:07:30 jgg Exp $ +// $Id: gzip.cc,v 1.2 1998/10/26 07:11:53 jgg Exp $ /* ###################################################################### GZip method - Take a file URI in and decompress it into the target @@ -123,20 +123,25 @@ int main() { dup2(From.Fd(),STDIN_FILENO); dup2(To.Fd(),STDOUT_FILENO); + From.Close(); + To.Close(); + SetCloseExec(STDIN_FILENO,false); + SetCloseExec(STDOUT_FILENO,false); const char *Args[3]; - Args[0] = _config->FindFile("Dir::bin::gzip","gzip").c_str(); + Args[0] = _config->Find("Dir::bin::gzip","gzip").c_str(); Args[1] = "-d"; Args[2] = 0; execvp(Args[0],(char **)Args); + exit(100); } From.Close(); - To.Close(); // Wait for gzip to finish int Status; if (waitpid(Process,&Status,0) != Process) { + To.OpFail(); _error->Errno("wait","Waiting for gzip failed"); Fail(URI); continue; @@ -144,11 +149,14 @@ int main() if (WIFEXITED(Status) == 0 || WEXITSTATUS(Status) != 0) { + To.OpFail(); _error->Error("gzip failed, perhaps the disk is full or the directory permissions are wrong."); Fail(URI); continue; } + To.Close(); + // Transfer the modification times struct stat Buf; if (stat(File.c_str(),&Buf) != 0) -- cgit v1.2.3-70-g09d2