-Vacuum before exit

This commit is contained in:
tonikelope 2016-10-03 22:04:48 +02:00
parent e69184f726
commit b1da373fef
3 changed files with 24 additions and 8 deletions

View File

@ -27,6 +27,14 @@ public final class DBTools {
}
}
public static void vaccum() throws SQLException {
try (Connection conn = SqliteSingleton.getInstance().getConn(); Statement stat = conn.createStatement()) {
stat.execute("VACUUM");
}
}
public static void insertDownload(String url, String path, String filename, String filekey, Long size, String filepass, String filenoexpire) throws SQLException {
try (Connection conn = SqliteSingleton.getInstance().getConn(); PreparedStatement ps = conn.prepareStatement("INSERT INTO downloads (url, path, filename, filekey, filesize, filepass, filenoexpire) VALUES (?,?,?,?,?,?,?)")) {

View File

@ -31,6 +31,7 @@ import java.util.concurrent.ExecutorService;
import static java.util.concurrent.Executors.newCachedThreadPool;
import java.util.logging.Level;
import static java.util.logging.Level.SEVERE;
import java.util.logging.Logger;
import static java.util.logging.Logger.getLogger;
import static javax.swing.JOptionPane.QUESTION_MESSAGE;
import static javax.swing.JOptionPane.YES_NO_CANCEL_OPTION;
@ -340,6 +341,8 @@ public final class MainPanel {
public void _byebye() {
boolean exit = true;
if(!_streamserver.getWorking_threads().isEmpty()) {
Object[] options = {"No",
@ -352,9 +355,9 @@ public final class MainPanel {
options,
options[0]);
if(n==1) {
if(n==0) {
exit(0);
exit=false;
}
} else if(!getDownload_manager().getTransference_provision_queue().isEmpty() || !getUpload_manager().getTransference_provision_queue().isEmpty()) {
@ -369,16 +372,22 @@ public final class MainPanel {
options,
options[0]);
if(n==1) {
if(n==0) {
exit(0);
exit=false;
}
} else {
}
if(exit) {
try {
DBTools.vaccum();
} catch (SQLException ex) {
Logger.getLogger(MainPanel.class.getName()).log(Level.SEVERE, null, ex);
}
exit(0);
}
}

View File

@ -648,8 +648,7 @@ public final class MainPanelView extends javax.swing.JFrame {
}//GEN-LAST:event_about_menuActionPerformed
private void exit_menuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exit_menuActionPerformed
_main_panel._byebye();
}//GEN-LAST:event_exit_menuActionPerformed