From d8e3fdbabfa504cca4eb9dedac8859736785ad03 Mon Sep 17 00:00:00 2001 From: lodici Date: Sat, 25 Feb 2017 16:26:39 +0000 Subject: [PATCH] fix: stats folder was being created in project root when running from IDE. --- src/magic/data/stats/h2/H2Database.java | 7 +++++-- src/magic/utility/MagicFileSystem.java | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/magic/data/stats/h2/H2Database.java b/src/magic/data/stats/h2/H2Database.java index 1fe67be595..074cb7ca05 100644 --- a/src/magic/data/stats/h2/H2Database.java +++ b/src/magic/data/stats/h2/H2Database.java @@ -1,5 +1,6 @@ package magic.data.stats.h2; +import java.nio.file.Path; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -18,6 +19,7 @@ import magic.model.MagicPlayer; import magic.model.player.AiProfile; import magic.model.player.PlayerProfile; import magic.utility.DeckUtils; +import magic.utility.MagicFileSystem; import magic.utility.MagicSystem; import org.h2.jdbcx.JdbcConnectionPool; @@ -41,9 +43,10 @@ public class H2Database { } public static String getDatabaseFile() { + Path statsPath = MagicFileSystem.getDataPath(MagicFileSystem.DataPath.STATS); return MagicSystem.isDevMode() || MagicSystem.isTestGame() - ? "./Magarena/stats/game-stats-dev" - : "./Magarena/stats/game-stats"; + ? statsPath.resolve("game-stats-dev").toAbsolutePath().toString() + : statsPath.resolve("game-stats").toAbsolutePath().toString(); } private JdbcConnectionPool getConnectionPool() { diff --git a/src/magic/utility/MagicFileSystem.java b/src/magic/utility/MagicFileSystem.java index 4053590714..5d94f22042 100644 --- a/src/magic/utility/MagicFileSystem.java +++ b/src/magic/utility/MagicFileSystem.java @@ -87,7 +87,8 @@ public final class MagicFileSystem { TRANSLATIONS("translations"), IMAGES("images"), REPORTS("reports"), - THEMES("themes") + THEMES("themes"), + STATS("stats") ; private final Path directoryPath;