]> git.saurik.com Git - apt.git/blobdiff - methods/mirror.cc
do not crash if the mirror file fails to download
[apt.git] / methods / mirror.cc
index 9d8202dad58340dfa1734bbe2850e53dbfc44ac4..00757e61f0a7a8ba65c13485042d444fc2c9c743 100644 (file)
@@ -160,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() ) {
@@ -356,8 +359,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()) {