mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-18 15:33:12 +09:00
Refactor controller mod storage into ModStore
Structure the storage of mods on the controller into into a reusable component in preparation for the host using the same kind of mod storage to retrieve and cache the mods it needs to run mod packs on instances.
This commit is contained in:
1 parent
448cfbbb51
commit
853866492b
9 files changed
+174
-91
No files matched your search
@@ -90,7 +90,17 @@ export default class ModInfo {
|
||||
* Expected name of zip file containing this mod.
|
||||
*/
|
||||
get filename() {
|
||||
return `${this.name}_${this.version}.zip`;
|
||||
return ModInfo.filename(this.name, this.version);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expected name of zip file containing mod with given name and version.
|
||||
* @param name - Mod's name
|
||||
* @param version - Mod's version
|
||||
* @returns string containing {name}_{version}.zip
|
||||
*/
|
||||
static filename(name: string, version: string) {
|
||||
return `${name}_${version}.zip`;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -114,15 +114,17 @@ export class ModGetRequest {
|
||||
constructor(
|
||||
public name: string,
|
||||
public version: string,
|
||||
public sha1?: string,
|
||||
) { }
|
||||
|
||||
static jsonSchema = Type.Object({
|
||||
"name": Type.String(),
|
||||
"version": Type.String(),
|
||||
"sha1": Type.Optional(Type.String()),
|
||||
});
|
||||
|
||||
static fromJSON(json: Static<typeof this.jsonSchema>) {
|
||||
return new this(json.name, json.version);
|
||||
return new this(json.name, json.version, json.sha1);
|
||||
}
|
||||
|
||||
static Response = ModInfo;
|
||||
@@ -198,22 +200,24 @@ export class ModSearchRequest {
|
||||
export class ModDownloadRequest {
|
||||
declare ["constructor"]: typeof ModDownloadRequest;
|
||||
static type = "request" as const;
|
||||
static src = "control" as const;
|
||||
static src = ["host", "control"] as const;
|
||||
static dst = "controller" as const;
|
||||
static permission = "core.mod.download" as const;
|
||||
|
||||
constructor(
|
||||
public name: string,
|
||||
public version: string,
|
||||
public sha1?: string,
|
||||
) { }
|
||||
|
||||
static jsonSchema = Type.Object({
|
||||
"name": Type.String(),
|
||||
"version": Type.String(),
|
||||
"sha1": Type.Optional(Type.String()),
|
||||
});
|
||||
|
||||
static fromJSON(json: Static<typeof this.jsonSchema>) {
|
||||
return new this(json.name, json.version);
|
||||
return new this(json.name, json.version, json.sha1);
|
||||
}
|
||||
|
||||
static Response = JsonString;
|
||||
|
||||
Reference in new issue
Block a user