X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/ae54c5356b2d0d9776528d1eeb773c57f5b82ef4..f744c64c591cec9e5aa489a9af55e1ed6d1871d1:/methods/mirror.cc diff --git a/methods/mirror.cc b/methods/mirror.cc index 7f28c04cb..854366318 100644 --- a/methods/mirror.cc +++ b/methods/mirror.cc @@ -8,6 +8,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include @@ -16,7 +18,8 @@ #include #include #include - +#include +#include #include #include @@ -34,7 +37,7 @@ using namespace std; #include "mirror.h" #include "http.h" -#include "apti18n.h" +#include /*}}}*/ /* Done: @@ -55,7 +58,7 @@ using namespace std; */ MirrorMethod::MirrorMethod() - : HttpMethod(), DownloadedMirrorFile(false) + : HttpMethod(), DownloadedMirrorFile(false), Debug(false) { }; @@ -108,7 +111,7 @@ bool MirrorMethod::Clean(string Dir) continue; // see if we have that uri - for(I=list.begin(); I != list.end(); I++) + for(I=list.begin(); I != list.end(); ++I) { string uri = (*I)->GetURI(); if(uri.find("mirror://") != 0) @@ -121,9 +124,10 @@ bool MirrorMethod::Clean(string Dir) if (I == list.end()) unlink(Dir->d_name); }; - - chdir(StartDir.c_str()); + closedir(D); + if (chdir(StartDir.c_str()) != 0) + return _error->Errno("chdir",_("Unable to change to %s"),StartDir.c_str()); return true; } @@ -144,9 +148,9 @@ bool MirrorMethod::DownloadMirrorFile(string mirror_uri_str) // append all architectures std::vector vec = APT::Configuration::getArchitectures(); for (std::vector::const_iterator I = vec.begin(); - I != vec.end(); I++) + I != vec.end(); ++I) if (I == vec.begin()) - fetch += "?arch" + (*I); + fetch += "?arch=" + (*I); else fetch += "&arch=" + (*I); @@ -307,6 +311,9 @@ bool MirrorMethod::InitMirrors() AllMirrors.push_back(s); } + if (AllMirrors.empty()) { + return _error->Error(_("No entry found in mirror file '%s'"), MirrorFile.c_str()); + } Mirror = AllMirrors[0]; UsedMirror = Mirror; return true; @@ -346,7 +353,7 @@ string MirrorMethod::GetMirrorFileName(string mirror_uri_str) vector::const_iterator I; pkgSourceList list; list.ReadMainList(); - for(I=list.begin(); I != list.end(); I++) + for(I=list.begin(); I != list.end(); ++I) { string uristr = (*I)->GetURI(); if(Debug)