From c9609259db644cb04b4c3cf29ca796361e8b0ef4 Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Sun, 11 Feb 2024 15:48:45 +0100 Subject: [PATCH] Ignore error loading mod in fetchMod If a bad download or file transfer causes a mod in a host's mod folder to become corrupt the attempt to load the mod will throw an error that's not the file not existing. This in turn causes starting the instance to always fail as the mod is never attempted to be re-downloaded. Fix by ignoring errors attempting to load mods already present in the mods folder that aren't in the mod store so that a new download is attempted after that fails. --- CHANGELOG.md | 1 + packages/host/src/Host.ts | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea1ac02f..485f1130 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - Fixed data export with a mod using shorthand notation for the default value of a color-setting causing the ModPack data to be set to invalid data. - Fixed per user per instance player stats not being deleted when the instance it's for is deleted. - Fixed mods setting the item prototype icons property to an object mapping instead of an array breaking the data export. +- Fixed a bad mod in the host's mods folder causing instance start to fail instead of the host re-downloading the mod. ## Version 2.0.0-alpha.16 diff --git a/packages/host/src/Host.ts b/packages/host/src/Host.ts index c2fc5d67..75e80ffa 100644 --- a/packages/host/src/Host.ts +++ b/packages/host/src/Host.ts @@ -600,8 +600,9 @@ export default class Host extends lib.Link { try { modInfo = await this.modStore.loadMod(mod.name, mod.version); } catch (err: any) { + // A broken zip file may have been left in the mods folder if (err.code !== "ENOENT") { - throw err; + logger.error(`Error loading mod ${mod.name} ${mod.version}: ${err.message}`); } } if (modInfo && (!mod.sha1 || mod.sha1 === modInfo.sha1)) {