diff --git a/src/main/java/com/gmail/picono435/picojobs/PicoJobsPlugin.java b/src/main/java/com/gmail/picono435/picojobs/PicoJobsPlugin.java index aac69f4d..4ad21b9a 100644 --- a/src/main/java/com/gmail/picono435/picojobs/PicoJobsPlugin.java +++ b/src/main/java/com/gmail/picono435/picojobs/PicoJobsPlugin.java @@ -219,6 +219,8 @@ public void onDisable() { sendConsoleMessage(Level.INFO, "Disconnecting connection to storage..."); jobs.clear(); + PicoJobsAPI.getStorageManager().destroyStorageFactory(); + if(wasUpdated && PicoJobsAPI.getStorageManager().getStorageFactory() instanceof H2Storage) { try { Script.main("-url jdbc:h2:$f -script $f.zip -options compression zip".replace("$f", PicoJobsPlugin.getInstance().getDataFolder().toPath().toAbsolutePath().resolve("storage").resolve("picojobs-h2").toAbsolutePath().toString()).split(" ")); @@ -226,8 +228,6 @@ public void onDisable() { e.printStackTrace(); } } - - PicoJobsAPI.getStorageManager().destroyStorageFactory(); sendConsoleMessage(Level.INFO, "The plugin was succefully disabled."); } diff --git a/src/main/java/com/gmail/picono435/picojobs/storage/sql/H2Storage.java b/src/main/java/com/gmail/picono435/picojobs/storage/sql/H2Storage.java index 55935d4e..e1429cb2 100644 --- a/src/main/java/com/gmail/picono435/picojobs/storage/sql/H2Storage.java +++ b/src/main/java/com/gmail/picono435/picojobs/storage/sql/H2Storage.java @@ -15,7 +15,9 @@ protected boolean initializeStorage() throws Exception { configurationSection = PicoJobsAPI.getSettingsManager().getRemoteSqlConfiguration(); if(PicoJobsPlugin.getInstance().getDataFolder().toPath().toAbsolutePath().resolve("storage").resolve("picojobs-h2.zip").toFile().exists()) { - RunScript.main("-url jdbc:h2:$f -script $f.zip -options compression zip variable_binary".replace("$f", PicoJobsPlugin.getInstance().getDataFolder().toPath().toAbsolutePath().resolve("storage").resolve("picojobs-h2").toAbsolutePath().toString()).split(" ")); + PicoJobsPlugin.getInstance().getDataFolder().toPath().toAbsolutePath().resolve("storage").resolve("picojobs-h2.mv.db").toFile().delete(); + RunScript.main("-url jdbc:h2:$f -script $f.zip -options compression zip".replace("$f", PicoJobsPlugin.getInstance().getDataFolder().toPath().toAbsolutePath().resolve("storage").resolve("picojobs-h2").toAbsolutePath().toString()).split(" ")); + PicoJobsPlugin.getInstance().getDataFolder().toPath().toAbsolutePath().resolve("storage").resolve("picojobs-h2.zip").toFile().delete(); } config.setDriverClassName("org.h2.Driver");