MCPcopy Create free account
hub / github.com/MCSManager/MCSManager / installMod

Method installMod

daemon/src/service/mod_service.ts:380–416  ·  view source on GitHub ↗
(
    instanceUuid: string,
    url: string,
    fileName: string,
    type: "mod" | "plugin",
    options: { fallbackUrl?: string } = {}
  )

Source from the content-addressed store, hash-verified

378 }
379
380 public async installMod(
381 instanceUuid: string,
382 url: string,
383 fileName: string,
384 type: "mod" | "plugin",
385 options: { fallbackUrl?: string } = {}
386 ) {
387 const instance = InstanceSubsystem.getInstance(instanceUuid)!;
388 const cwd = instance.absoluteCwdPath();
389 const fileManager = new FileManager(
390 resolveMCDRServerRoot(instance.config.type, cwd) ?? cwd,
391 instance.config?.fileCode
392 );
393 const rootDir = fileManager.toAbsolutePath(".");
394
395 // Determine the save directory based on what exists (case-sensitive check for Linux)
396 let saveDir = type === "plugin" ? "plugins" : "mods";
397 const variants = type === "plugin" ? ["plugins", "Plugins"] : ["mods", "Mods"];
398
399 for (const v of variants) {
400 if (await fs.pathExists(path.join(rootDir, v))) {
401 saveDir = v;
402 break;
403 }
404 }
405
406 const relativePath = path.join(saveDir, fileName);
407 if (!fileManager.checkPath(relativePath)) throw new Error("Invalid file path");
408 const targetPath = fileManager.toAbsolutePath(relativePath);
409
410 logger.info(
411 `[ModService] Instance ${instanceUuid} Install Mod: ${fileName} from ${url} to ${targetPath}`
412 );
413 logger.info(`[ModService] Options: ${JSON.stringify(options)}`);
414
415 await downloadManager.downloadFromUrl(url, targetPath, options.fallbackUrl);
416 }
417
418 public async getModConfig(
419 instanceUuid: string,

Callers 1

Instance_router.tsFile · 0.80

Calls 7

toAbsolutePathMethod · 0.95
checkPathMethod · 0.95
resolveMCDRServerRootFunction · 0.90
absoluteCwdPathMethod · 0.80
infoMethod · 0.80
downloadFromUrlMethod · 0.80
getInstanceMethod · 0.45

Tested by

no test coverage detected