summaryrefslogtreecommitdiff
path: root/methods/mirror.cc
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2011-03-24 17:58:06 +0100
committerMichael Vogt <michael.vogt@ubuntu.com>2011-03-24 17:58:06 +0100
commit4beb315f53061e537b923009e228981bb1e3fa7f (patch)
tree14abcb7738545cdd8ef9c26a13fbcd6c1784bf8a /methods/mirror.cc
parent3bceb058c0d1890eee923aa014c41ad458f88fb6 (diff)
parent0004842de7eeac345b614fa0b6bd241af0c4cc34 (diff)
merged from lp:~mvo/apt/mvo
Diffstat (limited to 'methods/mirror.cc')
-rw-r--r--methods/mirror.cc11
1 files changed, 8 insertions, 3 deletions
diff --git a/methods/mirror.cc b/methods/mirror.cc
index e499b054b..00757e61f 100644
--- a/methods/mirror.cc
+++ b/methods/mirror.cc
@@ -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() ) {
@@ -354,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()) {