1
0
Fork 0
mirror of synced 2024-06-28 02:50:50 +12:00

Overwrite existing plugins of the same name and version

This commit is contained in:
Andrew Kingston 2022-08-12 14:41:37 +01:00
parent b549fe114b
commit e9fc30afda

View file

@ -32,19 +32,18 @@ export async function upload(ctx: any) {
}
const jsFileName = jsFile.name
const pluginId = generatePluginID(name, version)
let existing
// overwrite existing docs entirely if they exist
let rev
try {
existing = await db.get(pluginId)
const existing = await db.get(pluginId)
rev = existing._rev
} catch (err) {
existing = null
}
if (existing) {
throw new Error(
`Plugin already exists: name: ${name}, version: ${version}`
)
rev = null
}
const doc = {
_id: pluginId,
_rev: rev,
name,
version,
description,