MCPcopy
hub / github.com/GooseMod/OpenAsar / initNew

Function initNew

src/splash/index.js:118–171  ·  view source on GitHub ↗
(inst)

Source from the content-addressed store, hash-verified

116}
117
118const initNew = async (inst) => {
119 toSend = -1;
120
121 const retryOptions = {
122 skip_host_delta: true,
123 skip_module_delta: {},
124 skip_all_module_delta: false,
125 allow_optional_updates: settings.get('ALLOW_OPTIONAL_UPDATES', true)
126 };
127
128 while (true) {
129 sendState('checking-for-updates');
130
131 try {
132 let installedAnything = false;
133 const downloads = new UIProgress(0);
134 const installs = new UIProgress(1);
135
136 await inst.updateToLatestWithOptions(retryOptions, ({ task, state, percent }) => {
137 const download = task.HostDownload || task.ModuleDownload;
138 const install = task.HostInstall || task.ModuleInstall;
139
140 installedAnything = true;
141
142 const simpleRecord = (tracker, x) => tracker.record(x.package_sha256, state, percent);
143
144 if (download != null) simpleRecord(downloads, download);
145
146 if (!downloads.send()) installs.send();
147
148 if (install == null) return;
149 simpleRecord(installs, install);
150
151 if (state === 'Failed') {
152 if (task.HostInstall != null) {
153 retryOptions.skip_host_delta = true;
154 } else if (task.ModuleInstall != null) {
155 retryOptions.skip_module_delta[install.version.module.name] = true;
156 }
157 }
158 });
159
160 if (!installedAnything) {
161 await inst.startCurrentVersion({});
162 inst.collectGarbage();
163
164 return launchMain();
165 }
166 } catch (e) {
167 log('Splash', e);
168 await new Promise(r => fail(r));
169 }
170 }
171};
172
173const initOld = () => { // "Old" (not v2 / new, win32 only)
174 const on = (k, v) => moduleUpdater.events.on(k, v);

Callers 1

index.jsFile · 0.85

Calls 9

sendMethod · 0.95
sendStateFunction · 0.85
simpleRecordFunction · 0.85
launchMainFunction · 0.85
failFunction · 0.85
getMethod · 0.80
startCurrentVersionMethod · 0.80
collectGarbageMethod · 0.80

Tested by

no test coverage detected