bool CRapidDownloader::download_name(IDownload* download, int reccounter, std::string name) { LOG_DEBUG("%s %s", name.c_str(), download->name.c_str()); if (reccounter > 10) return false; LOG_DEBUG("Using rapid to download %s", download->name.c_str()); std::set<std::string> downloaded; for (CSdp& sdp : sdps) { if (!match_download_name(sdp.getName(), name.empty() ? download->name : name)) continue; if (downloaded.find(sdp.getMD5()) != downloaded.end()) // already downloaded, skip (i.e. stable entries are // twice in versions.gz) continue; downloaded.insert(sdp.getMD5()); LOG_INFO ("[Download] %s", sdp.getName().c_str()); if (!sdp.download(download)) { return false; } if (sdp.getDepends().empty()) continue; if (!download_name(download, reccounter + 1, sdp.getDepends())) { return false; } } return true; }
bool CRapidDownloader::search(std::list<IDownload*>& result, const std::string& name, IDownload::category /*cat*/) { LOG_DEBUG("%s",name.c_str()); reloadRepos(); sdps.sort(list_compare); std::list<CSdp>::iterator it; for (it=sdps.begin(); it!=sdps.end(); ++it) { if (match_download_name((*it).getShortName(),name) || (match_download_name((*it).getName(),name))) { IDownload* dl=new IDownload((*it).getName().c_str()); dl->addMirror((*it).getShortName().c_str()); result.push_back(dl); } } return true; }
/** search for a mod, searches for the short + long name */ std::list<IDownload>* CRapidDownloader::search(const std::string& name, IDownload::category cat){ DEBUG_LINE("%s",name.c_str()); reloadRepos(); std::list<IDownload>*tmp; tmp=new std::list<IDownload>; sdps.sort(list_compare); std::list<CSdp*>::iterator it; for (it=this->sdps.begin();it!=this->sdps.end();++it){ if (match_download_name((*it)->getShortName().c_str(),name) || (match_download_name((*it)->getName().c_str(),name))){ IDownload* dl=new IDownload((*it)->getShortName().c_str(),(*it)->getName().c_str()); tmp->push_back(*dl); } } return tmp; }
bool CRapidDownloader::search(std::list<IDownload*>& result, const std::string& name, DownloadEnum::Category cat) { LOG_DEBUG("%s", name.c_str()); updateRepos(name); sdps.sort(list_compare); for (CSdp& sdp : sdps) { if (match_download_name(sdp.getShortName(), name) || (match_download_name(sdp.getName(), name))) { IDownload* dl = new IDownload(sdp.getName().c_str(), name, cat, IDownload::TYP_RAPID); dl->addMirror(sdp.getShortName().c_str()); result.push_back(dl); } } return true; }
/** download by name, for example "Complete Annihilation revision 1234" */ bool CRapidDownloader::download_name(const std::string& longname, int reccounter){ DEBUG_LINE("%s",longname.c_str()); std::list<CSdp*>::iterator it; if (reccounter>10) return false; for (it=sdps.begin();it!=sdps.end();++it){ if (match_download_name((*it)->getName(),longname)){ printf("Found Depends, downloading %s\n", (*it)->getName().c_str()); if (!(*it)->download()) return false; if ((*it)->getDepends().length()>0){ if (!download_name((*it)->getDepends(),reccounter+1)) return false; } return true; } } return false; }
bool CRapidDownloader::download_name(const std::string& longname, int reccounter) { LOG_DEBUG("%s",longname.c_str()); std::list<CSdp>::iterator it; if (reccounter>10) return false; LOG_DEBUG("Using rapid"); for (it=sdps.begin(); it!=sdps.end(); ++it) { if (match_download_name((*it).getName(),longname)) { LOG_DOWNLOAD((it)->getName().c_str() ); if (!(*it).download()) return false; if ((*it).getDepends().length()>0) { if (!download_name((*it).getDepends(),reccounter+1)) return false; } return true; } } return false; }
bool CRapidDownloader::download_name(IDownload* download, int reccounter,std::string name) { LOG_DEBUG("%s %s",name.c_str(),download->name.c_str()); std::list<CSdp>::iterator it; if (reccounter>10) return false; LOG_DEBUG("Using rapid"); for (it=sdps.begin(); it!=sdps.end(); ++it) { if (match_download_name((*it).getName(),name.length() == 0 ? download->name : name )) { LOG_DOWNLOAD((it)->getName().c_str() ); if (!(*it).download(download)) return false; if ((*it).getDepends().length()>0) { if (!download_name(download,reccounter+1,(*it).getDepends())) return false; } return true; } } return false; }