Skip to content

Commit

Permalink
Fixed issues with H2 storage backing up and script running
Browse files Browse the repository at this point in the history
  • Loading branch information
Picono435 committed Mar 12, 2022
1 parent 07d1974 commit eb9aca0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,15 @@ 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(" "));
} catch (SQLException e) {
e.printStackTrace();
}
}

PicoJobsAPI.getStorageManager().destroyStorageFactory();

sendConsoleMessage(Level.INFO, "The plugin was succefully disabled.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit eb9aca0

Please sign in to comment.