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

Method finalize

launcher/net/FileSink.cpp:88–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86}
87
88Task::State FileSink::finalize(QNetworkReply& reply)
89{
90 bool gotFile = false;
91 QVariant statusCodeV = reply.attribute(QNetworkRequest::HttpStatusCodeAttribute);
92 bool validStatus = false;
93 int statusCode = statusCodeV.toInt(&validStatus);
94 if (validStatus) {
95 // this leaves out 304 Not Modified
96 gotFile = statusCode == 200 || statusCode == 203;
97 }
98
99 // if we wrote any data to the save file, we try to commit the data to the real file.
100 // if it actually got a proper file, we write it even if it was empty
101 if (gotFile || wroteAnyData) {
102 // ask validators for data consistency
103 // we only do this for actual downloads, not 'your data is still the same' cache hits
104 if (!finalizeAllValidators(reply))
105 return Task::State::Failed;
106
107 // nothing went wrong...
108 if (!m_output_file->commit()) {
109 qCritical() << "Failed to commit changes to " << m_filename;
110 m_output_file->cancelWriting();
111 return Task::State::Failed;
112 }
113 }
114
115 // then get rid of the save file
116 m_output_file.reset();
117
118 return finalizeCache(reply);
119}
120
121Task::State FileSink::initCache(QNetworkRequest&)
122{

Callers 3

finalizeStepsMethod · 0.45
downloadFinishedMethod · 0.45
downloadFinishedMethod · 0.45

Calls 1

resetMethod · 0.45

Tested by

no test coverage detected