diff options
Diffstat (limited to 'methods')
-rw-r--r-- | methods/bzip2.cc | 9 | ||||
-rw-r--r-- | methods/gzip.cc | 9 |
2 files changed, 6 insertions, 12 deletions
diff --git a/methods/bzip2.cc b/methods/bzip2.cc index 241f21c66..c668141a2 100644 --- a/methods/bzip2.cc +++ b/methods/bzip2.cc @@ -56,12 +56,9 @@ bool Bzip2Method::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; - } + // FIXME add an error message saying that empty files can't be valid archives + if(From.Size() == 0) + return false; int GzOut[2]; if (pipe(GzOut) < 0) diff --git a/methods/gzip.cc b/methods/gzip.cc index 5b9b66b50..22cae9424 100644 --- a/methods/gzip.cc +++ b/methods/gzip.cc @@ -48,12 +48,9 @@ bool GzipMethod::Fetch(FetchItem *Itm) // Open the source and destination files FileFd From(Path,FileFd::ReadOnlyGzip); - // if the file is empty, just rename it and return - if(From.Size() == 0) - { - rename(Path.c_str(), Itm->DestFile.c_str()); - return true; - } + // FIXME add an error message saying that empty files can't be valid archives + if(From.Size() == 0) + return false; FileFd To(Itm->DestFile,FileFd::WriteAtomic); To.EraseOnFailure(); |