MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / getDownloads

Method getDownloads

launcher/minecraft/Library.cpp:82–239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80}
81
82QList<NetAction::Ptr> Library::getDownloads(
83 const RuntimeContext & runtimeContext,
84 class HttpMetaCache* cache,
85 QStringList& failedLocalFiles,
86 const QString & overridePath
87) const
88{
89 QList<NetAction::Ptr> out;
90 bool stale = isAlwaysStale();
91 bool local = isLocal();
92
93 auto check_local_file = [&](QString storage)
94 {
95 QFileInfo fileinfo(storage);
96 QString fileName = fileinfo.fileName();
97 auto fullPath = FS::PathCombine(overridePath, fileName);
98 QFileInfo localFileInfo(fullPath);
99 if(!localFileInfo.exists())
100 {
101 failedLocalFiles.append(localFileInfo.filePath());
102 return false;
103 }
104 return true;
105 };
106
107 auto add_download = [&](QString storage, QString url, QString sha1)
108 {
109 if(local)
110 {
111 return check_local_file(storage);
112 }
113 auto entry = cache->resolveEntry("libraries", storage);
114 if(stale)
115 {
116 entry->setStale(true);
117 }
118 if (!entry->isStale())
119 return true;
120 Net::Download::Options options;
121 if(stale)
122 {
123 options |= Net::Download::Option::AcceptLocalFiles;
124 }
125
126 // Don't add a time limit for the libraries cache entry validity
127 options |= Net::Download::Option::MakeEternal;
128
129 if(sha1.size())
130 {
131 auto rawSha1 = QByteArray::fromHex(sha1.toLatin1());
132 auto dl = Net::Download::makeCached(url, entry, options);
133 dl->addValidator(new Net::ChecksumValidator(QCryptographicHash::Sha1, rawSha1));
134 qDebug() << "Checksummed Download for:" << rawName().serialize() << "storage:" << storage << "url:" << url;
135 out.append(dl);
136 }
137 else
138 {
139 out.append(Net::Download::makeCached(url, entry, options));

Callers 11

executeTaskMethod · 0.80
test_legacy_urlMethod · 0.80
test_legacy_nativeMethod · 0.80
test_onenineMethod · 0.80
test_onenine_nativeMethod · 0.80

Calls 15

PathCombineFunction · 0.85
QStringClass · 0.85
existsMethod · 0.80
appendMethod · 0.80
filePathMethod · 0.80
resolveEntryMethod · 0.80
isStaleMethod · 0.80
getDownloadInfoMethod · 0.80
isEmptyMethod · 0.80
setStaleMethod · 0.45
sizeMethod · 0.45
addValidatorMethod · 0.45