MCPcopy Create free account
hub / github.com/MultiMC/Launcher / load

Method load

launcher/meta/BaseEntity.cpp:105–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103}
104
105void Meta::BaseEntity::load(Net::Mode loadType)
106{
107 // load local file if nothing is loaded yet
108 if(!isLoaded())
109 {
110 if(loadLocalFile())
111 {
112 m_loadStatus = LoadStatus::Local;
113 }
114 }
115 // if we need remote update, run the update task
116 if(loadType == Net::Mode::Offline || !shouldStartRemoteUpdate())
117 {
118 return;
119 }
120 m_updateTask = new NetJob(QObject::tr("Download of meta file %1").arg(localFilename()));
121 auto url = this->url();
122 auto entry = APPLICATION->metacache()->resolveEntry("meta", localFilename());
123 entry->setStale(true);
124 auto dl = Net::Download::makeCached(url, entry);
125 /*
126 * The validator parses the file and loads it into the object.
127 * If that fails, the file is not written to storage.
128 */
129 dl->addValidator(new ParsingValidator(this));
130 m_updateTask->addNetAction(dl);
131 m_updateStatus = UpdateStatus::InProgress;
132 QObject::connect(m_updateTask.get(), &NetJob::succeeded, [&]()
133 {
134 m_loadStatus = LoadStatus::Remote;
135 m_updateStatus = UpdateStatus::Succeeded;
136 m_updateTask.reset();
137 });
138 QObject::connect(m_updateTask.get(), &NetJob::failed, [&]()
139 {
140 m_updateStatus = UpdateStatus::Failed;
141 m_updateTask.reset();
142 });
143 m_updateTask->start(APPLICATION->network());
144}
145
146bool Meta::BaseEntity::isLoaded() const
147{

Callers 1

selectLanguageMethod · 0.45

Calls 10

urlMethod · 0.95
resolveEntryMethod · 0.80
metacacheMethod · 0.80
addNetActionMethod · 0.80
networkMethod · 0.80
setStaleMethod · 0.45
addValidatorMethod · 0.45
getMethod · 0.45
resetMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected