1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/repo/RepoMirrorList.cc
15 #include "zypp/repo/RepoMirrorList.h"
16 #include "zypp/media/MetaLinkParser.h"
17 #include "zypp/MediaSetAccess.h"
18 #include "zypp/base/LogTools.h"
22 ///////////////////////////////////////////////////////////////////
24 { /////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////
27 { /////////////////////////////////////////////////////////////////
29 RepoMirrorList::RepoMirrorList( const Url &url )
31 Pathname filepath (url.getPathName());
33 std::vector<Url> my_urls;
35 DBG << "Getting MirrorList from URL: " << abs_url << endl;
37 abs_url.setPathName("");
38 abs_url.setQueryParam("mediahandler", "curl");
40 MediaSetAccess access (abs_url);
41 Pathname tmpfile = access.provideFile(filepath);
43 InputStream tmpfstream (tmpfile);
45 if ( url.asString().find("/metalink") != string::npos )
47 media::MetaLinkParser metalink;
48 metalink.parse(tmpfstream);
49 my_urls = metalink.getUrls();
54 while (getline(tmpfstream.stream(), tmpurl))
56 my_urls.push_back(Url(tmpurl));
61 for (std::vector<Url>::iterator it = my_urls.begin() ; it != my_urls.end() and valid_urls < 4 ; ++it)
63 if ( it->getScheme() != "rsync" )
65 size_t delpos = it->getPathName().find("repodata/repomd.xml");
66 if( delpos != string::npos )
68 it->setPathName( it->getPathName().erase(delpos) );
76 std::vector<Url> RepoMirrorList::getUrls() const
81 RepoMirrorList::~RepoMirrorList()
84 /////////////////////////////////////////////////////////////////
86 ///////////////////////////////////////////////////////////////////
87 /////////////////////////////////////////////////////////////////
89 ///////////////////////////////////////////////////////////////////