fix: stats folder was being created in project root when running from IDE.

master
lodici 2017-02-25 16:26:39 +00:00
parent 1334522c5f
commit d8e3fdbabf
2 changed files with 7 additions and 3 deletions

View File

@ -1,5 +1,6 @@
package magic.data.stats.h2; package magic.data.stats.h2;
import java.nio.file.Path;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
@ -18,6 +19,7 @@ import magic.model.MagicPlayer;
import magic.model.player.AiProfile; import magic.model.player.AiProfile;
import magic.model.player.PlayerProfile; import magic.model.player.PlayerProfile;
import magic.utility.DeckUtils; import magic.utility.DeckUtils;
import magic.utility.MagicFileSystem;
import magic.utility.MagicSystem; import magic.utility.MagicSystem;
import org.h2.jdbcx.JdbcConnectionPool; import org.h2.jdbcx.JdbcConnectionPool;
@ -41,9 +43,10 @@ public class H2Database {
} }
public static String getDatabaseFile() { public static String getDatabaseFile() {
Path statsPath = MagicFileSystem.getDataPath(MagicFileSystem.DataPath.STATS);
return MagicSystem.isDevMode() || MagicSystem.isTestGame() return MagicSystem.isDevMode() || MagicSystem.isTestGame()
? "./Magarena/stats/game-stats-dev" ? statsPath.resolve("game-stats-dev").toAbsolutePath().toString()
: "./Magarena/stats/game-stats"; : statsPath.resolve("game-stats").toAbsolutePath().toString();
} }
private JdbcConnectionPool getConnectionPool() { private JdbcConnectionPool getConnectionPool() {

View File

@ -87,7 +87,8 @@ public final class MagicFileSystem {
TRANSLATIONS("translations"), TRANSLATIONS("translations"),
IMAGES("images"), IMAGES("images"),
REPORTS("reports"), REPORTS("reports"),
THEMES("themes") THEMES("themes"),
STATS("stats")
; ;
private final Path directoryPath; private final Path directoryPath;