]> git.saurik.com Git - apt.git/commitdiff
merged from debian-sid
authorMichael Vogt <michael.vogt@ubuntu.com>
Tue, 5 Apr 2011 09:58:09 +0000 (11:58 +0200)
committerMichael Vogt <michael.vogt@ubuntu.com>
Tue, 5 Apr 2011 09:58:09 +0000 (11:58 +0200)
debian/changelog
methods/mirror.cc

index 03bbe86d42a669aedb574db4463d2d06a2776a40..46d677421b612223dfe58debe0abce10610226e6 100644 (file)
@@ -1,3 +1,15 @@
+apt (0.8.13.3) unstable; urgency=low
+
+  [ Thorsten Spindler ]
+  * debian/zzapt.cron.daily:
+    - move cron job to the end of execution (LP: #727685)
+  
+  [ Michael Vogt ]
+  * mirror method:
+    - do not crash if the mirror file fails to download
+
+ -- Michael Vogt <michael.vogt@ubuntu.com>  Thu, 10 Mar 2011 15:56:54 +0100
+
 apt (0.8.13.2) unstable; urgency=low
 
   [ David Kalnischkies ]
index e499b054b15edb0e36a62bf08417a6867e6aeba4..2cf5c9ce1110a9d7f9b259cf9913451b89126d94 100644 (file)
@@ -141,8 +141,10 @@ bool MirrorMethod::DownloadMirrorFile(string mirror_uri_str)
    pkgAcquire Fetcher;
    new pkgAcqFile(&Fetcher, fetch, "", 0, "", "", "", MirrorFile);
    bool res = (Fetcher.Run() == pkgAcquire::Continue);
-   if(res)
+   if(res) {
       DownloadedMirrorFile = true;
+      chmod(MirrorFile.c_str(), 0644);
+   }
    Fetcher.Shutdown();
 
    if(Debug)
@@ -158,6 +160,9 @@ bool MirrorMethod::RandomizeMirrorFile(string mirror_file)
    vector<string> content;
    string line;
 
+   if (!FileExists(mirror_file))
+      return false;
+
    // read 
    ifstream in(mirror_file.c_str());
    while ( !in.eof() ) {
@@ -251,6 +256,13 @@ bool MirrorMethod::InitMirrors()
       return _error->Error(_("No mirror file '%s' found "), MirrorFile.c_str());
    }
 
+   if (access(MirrorFile.c_str(), R_OK) != 0)
+   {
+      // FIXME: fallback to a default mirror here instead 
+      //        and provide a config option to define that default
+      return _error->Error(_("Can not read mirror file '%s'"), MirrorFile.c_str());
+   }  
+
    // FIXME: make the mirror selection more clever, do not 
    //        just use the first one!
    // BUT: we can not make this random, the mirror has to be
@@ -354,8 +366,8 @@ bool MirrorMethod::Fetch(FetchItem *Itm)
    if(Itm->IndexFile && !DownloadedMirrorFile)
    {
       Clean(_config->FindDir("Dir::State::mirrors"));
-      DownloadMirrorFile(Itm->Uri);
-      RandomizeMirrorFile(MirrorFile);
+      if (DownloadMirrorFile(Itm->Uri))
+         RandomizeMirrorFile(MirrorFile);
    }
 
    if(AllMirrors.empty()) {