From 997ff69e62e4fb7dc9486edc41b6c6fc11c0315f Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sun, 4 Sep 2022 22:33:18 -0500 Subject: [PATCH] fix(modrinth): create mods directory as needed --- .../me/itzg/helpers/modrinth/ModrinthCommand.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/me/itzg/helpers/modrinth/ModrinthCommand.java b/src/main/java/me/itzg/helpers/modrinth/ModrinthCommand.java index 8477f395..e9ce3a37 100644 --- a/src/main/java/me/itzg/helpers/modrinth/ModrinthCommand.java +++ b/src/main/java/me/itzg/helpers/modrinth/ModrinthCommand.java @@ -177,9 +177,13 @@ private Path download(ProjectType projectType, VersionFile versionFile) { if (projectType != ProjectType.mod) { throw new IllegalStateException("Only mod project types can be downloaded for now"); } - final Path outPath = outputDirectory - .resolve(MODS_SUBDIR) - .resolve(versionFile.getFilename()); + final Path outPath; + try { + outPath = Files.createDirectories(outputDirectory.resolve(MODS_SUBDIR)) + .resolve(versionFile.getFilename()); + } catch (IOException e) { + throw new RuntimeException("Creating mods directory", e); + } try { return fetch(URI.create(versionFile.getUrl())) @@ -187,7 +191,7 @@ private Path download(ProjectType projectType, VersionFile versionFile) { .skipExisting(true) .execute(); } catch (IOException e) { - throw new RuntimeException(e); + throw new RuntimeException("Downloading mod file", e); } }