Overwrite existing plugins of the same name and version
This commit is contained in:
parent
ceb3eb78e5
commit
8eb6400252
|
@ -32,19 +32,18 @@ export async function upload(ctx: any) {
|
||||||
}
|
}
|
||||||
const jsFileName = jsFile.name
|
const jsFileName = jsFile.name
|
||||||
const pluginId = generatePluginID(name, version)
|
const pluginId = generatePluginID(name, version)
|
||||||
let existing
|
|
||||||
|
// overwrite existing docs entirely if they exist
|
||||||
|
let rev
|
||||||
try {
|
try {
|
||||||
existing = await db.get(pluginId)
|
const existing = await db.get(pluginId)
|
||||||
|
rev = existing._rev
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
existing = null
|
rev = null
|
||||||
}
|
|
||||||
if (existing) {
|
|
||||||
throw new Error(
|
|
||||||
`Plugin already exists: name: ${name}, version: ${version}`
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
const doc = {
|
const doc = {
|
||||||
_id: pluginId,
|
_id: pluginId,
|
||||||
|
_rev: rev,
|
||||||
name,
|
name,
|
||||||
version,
|
version,
|
||||||
description,
|
description,
|
||||||
|
|
Loading…
Reference in New Issue