From: Michael Vogt Date: Thu, 24 Mar 2011 16:45:20 +0000 (+0100) Subject: do not crash if the mirror file fails to download X-Git-Tag: 0.9.13.exp1ubuntu1~198^2 X-Git-Url: https://git.saurik.com/apt.git/commitdiff_plain/0004842de7eeac345b614fa0b6bd241af0c4cc34?hp=83e6798e72fabee7ec333a7e897b095cda688c45 do not crash if the mirror file fails to download --- diff --git a/debian/changelog b/debian/changelog index 6ccb3dede..fc883dc0d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -15,6 +15,7 @@ apt (0.8.13) unstable; urgency=low - when downloading data, show the mirror being used - randomize mirror list to ensure more even load - merge fix from Matt Zimmerman, many thanks (LP: #741098) + - do not crash if the mirror file fails to download -- Michael Vogt Thu, 10 Mar 2011 15:56:54 +0100 diff --git a/methods/mirror.cc b/methods/mirror.cc index 9d8202dad..00757e61f 100644 --- a/methods/mirror.cc +++ b/methods/mirror.cc @@ -160,6 +160,9 @@ bool MirrorMethod::RandomizeMirrorFile(string mirror_file) vector 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()) {