mirror of
https://github.com/ivabus/gui
synced 2025-04-23 14:07:14 +03:00
handle deleting packages that do not exist more gracefully (#681)
This commit is contained in:
parent
b85c996c15
commit
6f0ece0704
2 changed files with 9 additions and 4 deletions
|
@ -153,9 +153,13 @@ export async function deletePackageFolder(fullName, version) {
|
||||||
try {
|
try {
|
||||||
const foldPath = path.join(getTeaPath(), fullName, `v${version}`);
|
const foldPath = path.join(getTeaPath(), fullName, `v${version}`);
|
||||||
log.info("rm:", foldPath);
|
log.info("rm:", foldPath);
|
||||||
await fs.rmSync(foldPath, { recursive: true });
|
fs.rmSync(foldPath, { recursive: true });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error(error);
|
if (error.code === "ENOENT") {
|
||||||
|
log.info(`Attempted to delete non-existent folder: ${fullName} v${version}`);
|
||||||
|
} else {
|
||||||
|
log.error(error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -243,8 +243,8 @@ const installPkg = async (pkg: GUIPackage, version?: string) => {
|
||||||
await installPackage(pkg, versionToInstall);
|
await installPackage(pkg, versionToInstall);
|
||||||
trackInstall(pkg.full_name);
|
trackInstall(pkg.full_name);
|
||||||
|
|
||||||
// If the package was AVAILABLE previously then it was just installed, otherwise it was updated
|
// If the package was NEEDS_UPDATE previously then it was updated, otherwise it was just installed
|
||||||
const state = pkg.state === PackageStates.AVAILABLE ? "INSTALLED" : "UPDATED";
|
const state = pkg.state === PackageStates.NEEDS_UPDATE ? "UPDATED" : "INSTALLED";
|
||||||
updatePackage(pkg.full_name, { displayState: { state, version: versionToInstall } });
|
updatePackage(pkg.full_name, { displayState: { state, version: versionToInstall } });
|
||||||
|
|
||||||
await refreshSinglePackage(pkg.full_name);
|
await refreshSinglePackage(pkg.full_name);
|
||||||
|
@ -275,6 +275,7 @@ const uninstallPkg = async (pkg: GUIPackage) => {
|
||||||
await deletePkg(pkg, v);
|
await deletePkg(pkg, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resetPackageDisplayState(pkg);
|
||||||
await refreshSinglePackage(pkg.full_name);
|
await refreshSinglePackage(pkg.full_name);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error(error);
|
log.error(error);
|
||||||
|
|
Loading…
Reference in a new issue