Do not load installation progress from cache (#527)

This commit is contained in:
ABevier 2023-04-29 18:55:45 -04:00 committed by GitHub
parent b39cc98e18
commit 8ee3f77abd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,7 +3,7 @@ import { mkdirp } from "mkdirp";
import fs from "fs"; import fs from "fs";
import log from "./logger"; import log from "./logger";
import { getTeaPath } from "./tea-dir"; import { getTeaPath } from "./tea-dir";
import { Packages } from "../../src/libs/types"; import { GUIPackage, Packages } from "../../src/libs/types";
const pkgsFilePath = path.join(getTeaPath(), "tea.xyz/gui/pkgs.json"); const pkgsFilePath = path.join(getTeaPath(), "tea.xyz/gui/pkgs.json");
const pkgsFolder = path.join(getTeaPath(), "tea.xyz/gui"); const pkgsFolder = path.join(getTeaPath(), "tea.xyz/gui");
@ -28,7 +28,16 @@ export async function loadPackageCache(): Promise<Packages> {
try { try {
log.info(`loading package cache from ${pkgsFilePath}`); log.info(`loading package cache from ${pkgsFilePath}`);
const pkgData = fs.readFileSync(pkgsFilePath); const pkgData = fs.readFileSync(pkgsFilePath);
return JSON.parse(pkgData.toString()) as Packages; const pkgs = JSON.parse(pkgData.toString()) as Packages;
if (pkgs?.packages) {
pkgs.packages = pkgs.packages.map((pkg: GUIPackage) => {
const { install_progress_percentage, isUninstalling, synced, ...rest } = pkg;
return rest;
});
}
return pkgs;
} catch (err) { } catch (err) {
if (err.code !== "ENOENT") { if (err.code !== "ENOENT") {
log.error(err); log.error(err);