]> git.saurik.com Git - apt.git/commitdiff
* rred.cc: use the d'tor of FileFd to close the file-fd; acquuire-item.cc: make the...
authorMichael Vogt <michael.vogt@ubuntu.com>
Mon, 22 Aug 2005 08:48:50 +0000 (08:48 +0000)
committerMichael Vogt <michael.vogt@ubuntu.com>
Mon, 22 Aug 2005 08:48:50 +0000 (08:48 +0000)
apt-pkg/acquire-item.cc
methods/rred.cc

index 166845868498201bffd8a9ad6ab171193ca581bf..43d29c737567e8ca36b86a88f5aa52017f548d1d 100644 (file)
@@ -218,9 +218,8 @@ string pkgAcqIndexDiffs::Custom600Headers()
 
 void pkgAcqIndexDiffs::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
 {
-   if(Debug)
-      std::clog << "Failed(): " << Desc.URI << std::endl
-               << "Falling back to big package file" << std::endl;
+   std::clog << "pkgAcqIndexDiffs failed: " << Desc.URI << std::endl
+            << "Falling back to normal index file aquire" << std::endl;
    new pkgAcqIndex(Owner, RealURI, Desc.Description,Desc.ShortDesc, 
                   ExpectedMD5);
    Finish();
@@ -268,9 +267,11 @@ bool pkgAcqIndexDiffs::QueueNextDiff()
    // remove all patches until the next matching patch is found
    // this requires the Index file to be ordered
    for(vector<DiffInfo>::iterator I=available_patches.begin();
-       I != available_patches.end() && (*I).sha1 != local_sha1; 
-       I++) 
+       available_patches.size() > 0 && I != available_patches.end() 
+         && (*I).sha1 != local_sha1; 
+       I++) {
       available_patches.erase(I);
+   }
 
    // error checking and falling back if no patch was found
    if(available_patches.size() == 0) { 
@@ -433,9 +434,11 @@ void pkgAcqIndexDiffs::Done(string Message,unsigned long Size,string Md5Hash,
       available_patches.erase(available_patches.begin());
 
       // move into place
-      if(Debug)
+      if(Debug) 
+      {
         std::clog << "Moving patched file in place: " << std::endl
                   << DestFile << " -> " << FinalFile << std::endl;
+      }
       Rename(DestFile,FinalFile);
 
       // see if there is more to download
index e28dc6855bb221e5cb2ef36fed08c6ab698c1852..3097fca022517ca6a90876ee1302b1cd34f1d0e3 100644 (file)
@@ -178,7 +178,8 @@ bool RredMethod::Fetch(FetchItem *Itm)
    URIStart(Res);
    // Res.Filename the destination filename
 
-   // Open the source and destination files
+   // Open the source and destination files (the d'tor of FileFd will do 
+   // the cleanup/closing of the fds)
    FileFd From(Path,FileFd::ReadOnly);
    FileFd Patch(Path+".ed",FileFd::ReadOnly);
    FileFd To(Itm->DestFile,FileFd::WriteEmpty);   
@@ -193,14 +194,6 @@ bool RredMethod::Fetch(FetchItem *Itm)
    // now do the actual patching
    ed_file(fPatch, fFrom, fTo, &Hash);
 
-   // clean up
-   fclose(fFrom);
-   fclose(fPatch);
-   fclose(fTo);
-   To.Close();
-   From.Close();
-   Patch.Close();
-   
    // XXX need to get the size 
    // Res.Size = Buf.st_size;
    Res.TakeHashes(Hash);