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

Method downloadFinished

launcher/net/Download.cpp:230–280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

228}
229
230void Download::downloadFinished()
231{
232 // handle HTTP redirection first
233 if (handleRedirect()) {
234 qDebug() << "Download redirected:" << m_url.toString();
235 return;
236 }
237
238 // if the download failed before this point ...
239 if (m_state == State::Succeeded) // pretend to succeed so we continue processing :)
240 {
241 qDebug() << "Download failed but we are allowed to proceed:" << m_url.toString();
242 m_sink->abort();
243 m_reply.reset();
244 emit succeeded();
245 return;
246 } else if (m_state == State::Failed) {
247 qDebug() << "Download failed in previous step:" << m_url.toString();
248 m_sink->abort();
249 m_reply.reset();
250 emit failed("");
251 return;
252 } else if (m_state == State::AbortedByUser) {
253 qDebug() << "Download aborted in previous step:" << m_url.toString();
254 m_sink->abort();
255 m_reply.reset();
256 emit aborted();
257 return;
258 }
259
260 // make sure we got all the remaining data, if any
261 auto data = m_reply->readAll();
262 if (data.size()) {
263 qDebug() << "Writing extra" << data.size() << "bytes";
264 m_state = m_sink->write(data);
265 }
266
267 // otherwise, finalize the whole graph
268 m_state = m_sink->finalize(*m_reply.get());
269 if (m_state != State::Succeeded) {
270 qDebug() << "Download failed to finalize:" << m_url.toString();
271 m_sink->abort();
272 m_reply.reset();
273 emit failed("");
274 return;
275 }
276
277 m_reply.reset();
278 qDebug() << "Download succeeded:" << m_url.toString();
279 emit succeeded();
280}
281
282void Download::downloadReadyRead()
283{

Callers

nothing calls this directly

Calls 7

toStringMethod · 0.45
abortMethod · 0.45
resetMethod · 0.45
sizeMethod · 0.45
writeMethod · 0.45
finalizeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected