mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-20 07:43:12 +09:00
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:
1 parent
7d34c60dd1
commit
7072b94355
7 files changed
+39
-28
No files matched your search
@@ -420,15 +420,15 @@ class Master {
|
||||
continue;
|
||||
}
|
||||
|
||||
let key = `${modInfo.name}_${modInfo.version}`;
|
||||
if (mods.has(key)) {
|
||||
if (modInfo.filename !== entry.name) {
|
||||
logger.error(
|
||||
`Ignoring Mod ${entry.name} as it contains the same name and ` +
|
||||
`version as ${mods.get(key).filename}`
|
||||
`Mod ${entry.name}'s filename does not match the expected ` +
|
||||
`name ${modInfo.filename}, it will be ignored.`
|
||||
);
|
||||
continue;
|
||||
}
|
||||
mods.set(key, modInfo);
|
||||
|
||||
mods.set(modInfo.filename, modInfo);
|
||||
}
|
||||
return mods;
|
||||
}
|
||||
@@ -454,15 +454,15 @@ class Master {
|
||||
}
|
||||
|
||||
async deleteMod(name, version) {
|
||||
let key = `${name}_${version}`;
|
||||
let mod = this.mods.get(key);
|
||||
let filename = `${name}_${version}.zip`;
|
||||
let mod = this.mods.get(filename);
|
||||
if (!mod) {
|
||||
throw new Error(`Mod ${key} does not exist`);
|
||||
throw new Error(`Mod ${filename} does not exist`);
|
||||
}
|
||||
|
||||
let modsDirectory = this.config.get("master.mods_directory");
|
||||
await fs.unlink(path.join(modsDirectory, mod.filename));
|
||||
this.mods.delete(key);
|
||||
await fs.unlink(path.join(modsDirectory, filename));
|
||||
this.mods.delete(filename);
|
||||
mod.isDeleted = true;
|
||||
this.modUpdated(mod);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user