diff options
author | Michael Vogt <michael.vogt@ubuntu.com> | 2011-03-24 17:45:20 +0100 |
---|---|---|
committer | Michael Vogt <michael.vogt@ubuntu.com> | 2011-03-24 17:45:20 +0100 |
commit | 0004842de7eeac345b614fa0b6bd241af0c4cc34 (patch) | |
tree | 54a44e3a88c6426bd1257e60768f974c8f2e736c /methods/mirror.cc | |
parent | 83e6798e72fabee7ec333a7e897b095cda688c45 (diff) |
do not crash if the mirror file fails to download
Diffstat (limited to 'methods/mirror.cc')
-rw-r--r-- | methods/mirror.cc | 7 |
1 files changed, 5 insertions, 2 deletions
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<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()) { |