fix: admin/plugins: installing 2 plugins with same repo-name and "hfs-" prefix will result in overwriting of the existing one
Massimo Melina committed
Apr 4, 2026 at 20:04 UTC
ce89409bd79dd30db1e90e173a34f8b22d254548
1 file changed
+3
-2
src/github.ts
+3
-2
@@ -77,9 +77,10 @@ export async function downloadPlugin(repo: Repo, { branch='', overwrite=false }=
77
const short = repo.split('/')[1] // second part, repo without the owner
78
if (!short)
79
throw new ApiError(HTTP_BAD_REQUEST, "bad repo")
80
+ const shortFolder = short.replace(/^hfs-/, '') || short
81
const folder = overwrite && pl?.id // use existing folder
81
- || (getFolder2repo().hasOwnProperty(short) ? repo.replace('/','-') // longer form only if another plugin is using short form, to avoid overwriting
82
- : short.replace(/^hfs-/, ''))
82
+ || (getFolder2repo().hasOwnProperty(shortFolder) ? repo.replace('/','-') // longer form only if another plugin is using short form, to avoid overwriting
83
+ : shortFolder)
84
const GITHUB_ZIP_ROOT = short + '-' + branch // GitHub puts everything within this folder
85
return await go(`https://github.com/${repo}/archive/refs/heads/${branch}.zip`, folder, GITHUB_ZIP_ROOT + '/' + DIST_ROOT)
86