mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-22 08:13:12 +09:00
Filter out missing files on load
This commit is contained in:
1 parent
f0fb471ea1
commit
8831b33c01
1 file changed
+7
-7
@@ -77,16 +77,16 @@ export class SaveModule {
|
|||||||
|
|
||||||
static async fromSave(json: Static<typeof SaveModule.jsonSchema>, root: JSZip) {
|
static async fromSave(json: Static<typeof SaveModule.jsonSchema>, root: JSZip) {
|
||||||
const module = new this(lib.ModuleInfo.fromJSON(json));
|
const module = new this(lib.ModuleInfo.fromJSON(json));
|
||||||
module.files = new Map(
|
module.files = new Map(await Promise.all(json.files
|
||||||
await Promise.all(json.files.map(async filename => {
|
.map(filename => ({filename, file: root.file(filename)}))
|
||||||
const file = root.file(filename);
|
.filter(({filename, file}) => {
|
||||||
if (file === null) {
|
if (file === null) {
|
||||||
lib.logger.warn(`Missing file ${filename} in save`);
|
lib.logger.warn(`Missing file ${filename} in save`);
|
||||||
return [filename, Buffer.alloc(0)] as const;
|
|
||||||
}
|
}
|
||||||
return [filename, await file.async("nodebuffer")] as const;
|
return file !== null;
|
||||||
}))
|
})
|
||||||
);
|
.map(async ({filename, file}) => [filename, await file!.async("nodebuffer")] as const)
|
||||||
|
));
|
||||||
return module;
|
return module;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user