Derive mod filename from name and version

Enforce the filename of uploaded mods match {name}_{version}.zip with
name and version taken from the zip file's info.json entry.  This allows
it to be used as a unique key for the mod and solves part of the issues
with mods having different number of leading zeros in their version.
This commit is contained in:
Hornwitser committed 2022-09-26 00:34:25 +02:00
1 parent 7d34c60dd1
commit 7072b94355
7 files changed
+39 -28

No files matched your search

+6 -6
View File
@@ -531,10 +531,10 @@ class ControlConnection extends BaseConnection {
async getModRequestHandler(message) {
let { name, version } = message.data;
let key = `${name}_${version}`;
let mod = this._master.mods.get(key);
let filename = `${name}_${version}.zip`;
let mod = this._master.mods.get(filename);
if (!mod) {
throw new libErrors.RequestError(`Mod ${key} does not exist`);
throw new libErrors.RequestError(`Mod ${filename} does not exist`);
}
return {
mod: mod.toJSON(),
@@ -639,10 +639,10 @@ class ControlConnection extends BaseConnection {
async downloadModRequestHandler(message) {
let { name, version } = message.data;
let key = `${name}_${version}`;
let mod = this._master.mods.get(key);
let filename = `${name}_${version}.zip`;
let mod = this._master.mods.get(filename);
if (!mod) {
throw new libErrors.RequestError(`Mod ${key} does not exist`);
throw new libErrors.RequestError(`Mod ${filename} does not exist`);
}
let modPath = path.join(this._master.config.get("master.mods_directory"), mod.filename);