]> git.saurik.com Git - apt.git/blobdiff - methods/gzip.cc
merged from donkult
[apt.git] / methods / gzip.cc
index 72e3ac90941fa904ca0de1e7d1ad1e73a9d351cf..fc4e1ecfd68c93cb9824ac74a7a6a3d2eadd662d 100644 (file)
@@ -48,14 +48,10 @@ bool GzipMethod::Fetch(FetchItem *Itm)
    // Open the source and destination files
    FileFd From(Path,FileFd::ReadOnlyGzip);
 
    // 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;
-   }
+   if(From.FileSize() == 0)
+      return _error->Error(_("Empty files can't be valid archives"));
 
 
-   FileFd To(Itm->DestFile,FileFd::WriteEmpty);   
+   FileFd To(Itm->DestFile,FileFd::WriteAtomic);   
    To.EraseOnFailure();
    if (_error->PendingError() == true)
       return false;
    To.EraseOnFailure();
    if (_error->PendingError() == true)
       return false;