Skip to content

Commit 9e2e7be

Browse files
authored
Merge pull request #337 from Java-Discord/moon/migration-fix
Fixed ClosedFileSystemException in /db-admin migrate
2 parents 5a77c6b + 28a353e commit 9e2e7be

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/main/java/net/javadiscord/javabot/data/h2db/MigrationUtils.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ public static Path getMigrationsDirectory() throws URISyntaxException, IOExcepti
3333
return Path.of(uri);
3434
} catch (FileSystemNotFoundException e) {
3535
Map<String, String> env = new HashMap<>();
36-
try (FileSystem dir = FileSystems.newFileSystem(uri, env)) {
37-
return dir.getPath("/database/migrations/");
38-
}
36+
FileSystem dir = FileSystems.newFileSystem(uri, env);
37+
return dir.getPath("/database/migrations/");
3938
}
4039
}
4140
}

src/main/java/net/javadiscord/javabot/data/h2db/commands/MigrateSubcommand.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public void execute(@NotNull SlashCommandInteractionEvent event) {
8181
return;
8282
}
8383
String sql = Files.readString(migrationFile);
84+
migrationsDir.getFileSystem().close();
8485
String[] statements = sql.split("\\s*;\\s*");
8586
if (statements.length == 0) {
8687
Responses.error(event, "The migration `" + migrationName + "` does not contain any statements. Please remove or edit it before running again.").queue();

0 commit comments

Comments
 (0)