handle deleting packages that do not exist more gracefully (#681)

This commit is contained in:
ABevier 2023-06-26 19:34:50 -04:00 committed by GitHub
parent b85c996c15
commit 6f0ece0704
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View file

@ -153,10 +153,14 @@ export async function deletePackageFolder(fullName, version) {
try {
const foldPath = path.join(getTeaPath(), fullName, `v${version}`);
log.info("rm:", foldPath);
await fs.rmSync(foldPath, { recursive: true });
fs.rmSync(foldPath, { recursive: true });
} catch (error) {
if (error.code === "ENOENT") {
log.info(`Attempted to delete non-existent folder: ${fullName} v${version}`);
} else {
log.error(error);
}
}
}
async function downloadImage(url: string, imagePath: string): Promise<void> {

View file

@ -243,8 +243,8 @@ const installPkg = async (pkg: GUIPackage, version?: string) => {
await installPackage(pkg, versionToInstall);
trackInstall(pkg.full_name);
// If the package was AVAILABLE previously then it was just installed, otherwise it was updated
const state = pkg.state === PackageStates.AVAILABLE ? "INSTALLED" : "UPDATED";
// If the package was NEEDS_UPDATE previously then it was updated, otherwise it was just installed
const state = pkg.state === PackageStates.NEEDS_UPDATE ? "UPDATED" : "INSTALLED";
updatePackage(pkg.full_name, { displayState: { state, version: versionToInstall } });
await refreshSinglePackage(pkg.full_name);
@ -275,6 +275,7 @@ const uninstallPkg = async (pkg: GUIPackage) => {
await deletePkg(pkg, v);
}
resetPackageDisplayState(pkg);
await refreshSinglePackage(pkg.full_name);
} catch (error) {
log.error(error);