mirror of
https://github.com/kunkunsh/kunkun.git
synced 2025-04-11 17:29:44 +00:00
refactor: enhance extension installation process with overwrite confirmation
if store extension exists in DB but not disk, also ask if need to overwrite it.
This commit is contained in:
parent
836a92cf14
commit
0af6ef2d0a
@ -81,7 +81,6 @@
|
|||||||
.installFromTarballUrl(tarballUrl, installDir, installExtras)
|
.installFromTarballUrl(tarballUrl, installDir, installExtras)
|
||||||
.then(() => toast.success(`Plugin ${ext.name} Installed`))
|
.then(() => toast.success(`Plugin ${ext.name} Installed`))
|
||||||
.then((loadedExt) => {
|
.then((loadedExt) => {
|
||||||
console.log("loadedExt", loadedExt);
|
|
||||||
supabaseAPI.incrementDownloads({
|
supabaseAPI.incrementDownloads({
|
||||||
identifier: ext.identifier,
|
identifier: ext.identifier,
|
||||||
version: ext.version
|
version: ext.version
|
||||||
@ -151,7 +150,6 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:window on:keydown={handleKeydown} />
|
<svelte:window on:keydown={handleKeydown} />
|
||||||
<Button onclick={() => toast.success("Hello")}>Toast</Button>
|
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
size="icon"
|
size="icon"
|
||||||
|
@ -55,6 +55,25 @@ export async function installTarball(
|
|||||||
}
|
}
|
||||||
await fs.remove(extInstallPath, { recursive: true })
|
await fs.remove(extInstallPath, { recursive: true })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// find extension in db, if exists, ask user if they want to overwrite it
|
||||||
|
const exts = await db.getAllExtensionsByIdentifier(manifest.kunkun.identifier)
|
||||||
|
if (exts.length > 0) {
|
||||||
|
const overwrite = await dialog.ask(
|
||||||
|
`Extension ${manifest.kunkun.identifier} already exists in database (but not on disk), do you want to overwrite it?`
|
||||||
|
)
|
||||||
|
if (!overwrite) {
|
||||||
|
return Promise.reject("Extension Already Exists")
|
||||||
|
}
|
||||||
|
if (exts[0].path) {
|
||||||
|
console.log(
|
||||||
|
"delete extension in db (overwrite in order to install a new version)",
|
||||||
|
exts[0].path
|
||||||
|
)
|
||||||
|
await db.deleteExtensionByPath(exts[0].path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
await fs.rename(decompressDest, extInstallPath)
|
await fs.rename(decompressDest, extInstallPath)
|
||||||
await db.createExtension({
|
await db.createExtension({
|
||||||
identifier: manifest.kunkun.identifier,
|
identifier: manifest.kunkun.identifier,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user