MCPcopy Index your code
hub / github.com/APKLab/APKLab / getUpdateConfig

Function getUpdateConfig

src/utils/updater.ts:171–193  ·  view source on GitHub ↗

* download the dynamic update data and save it locally. * refresh the local `config.json` file if it's older than 24h * @returns Config object with tools update data

()

Source from the content-addressed store, hash-verified

169 * @returns Config object with tools update data
170 */
171async function getUpdateConfig(): Promise<Config> {
172 const configFile = path.resolve(apklabDataDir, "config.json");
173 let configJsonData = { tools: [] };
174
175 if (fs.existsSync(configFile)) {
176 configJsonData = JSON.parse(fs.readFileSync(configFile, "utf-8"));
177 if (Date.now() - fs.statSync(configFile).mtimeMs < ONE_DAY_MS) {
178 return configJsonData;
179 }
180 }
181 try {
182 const buffer = await downloadFile(updaterConfigURL);
183 const config = JSON.parse(Buffer.from(buffer).toString("utf-8"));
184 if (config && config.tools) {
185 fs.writeFileSync(configFile, buffer);
186 return config;
187 }
188 } catch (err) {
189 outputChannel.appendLine(`Failed to download update config: ${err}`);
190 }
191
192 return configJsonData;
193}

Callers 2

updateToolsFunction · 0.85
checkAndInstallToolsFunction · 0.85

Calls 1

downloadFileFunction · 0.90

Tested by

no test coverage detected