From 1debbe348f06b80809cbdc85c5aaf1bfbde4efef Mon Sep 17 00:00:00 2001 From: lantzelot-swe <75668734+lantzelot-swe@users.noreply.github.com> Date: Sun, 2 Jan 2022 18:11:35 +0100 Subject: [PATCH] fix: When exporting games the export dialog is shown before old directories are deleted. Deleting from a USB stick can take a long time, the dialog was not shown before the delete was finished. --- src/main/java/se/lantz/gui/MenuManager.java | 16 ++++++++-------- .../gui/exports/ExportFileLoaderWorker.java | 6 ++++-- .../java/se/lantz/gui/exports/ExportWorker.java | 6 ++++-- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/main/java/se/lantz/gui/MenuManager.java b/src/main/java/se/lantz/gui/MenuManager.java index 846bca0..5cb3b42 100644 --- a/src/main/java/se/lantz/gui/MenuManager.java +++ b/src/main/java/se/lantz/gui/MenuManager.java @@ -954,8 +954,8 @@ public class MenuManager if (!viewList.isEmpty()) { exportManager.setGameViewsToExport(viewList); - exportManager.setTargetDirectory(exportSelectionDialog.getTargetDirectory(), - exportSelectionDialog.deleteBeforeExport()); + exportManager.setDeleteBeforeExport(exportSelectionDialog.deleteBeforeExport()); + exportManager.setTargetDirectory(exportSelectionDialog.getTargetDirectory()); ImportExportProgressDialog dialog = new ImportExportProgressDialog(this.mainWindow, "Export games", false); ExportWorker worker = new ExportWorker(exportManager, dialog); worker.execute(); @@ -968,8 +968,8 @@ public class MenuManager if (!gamesList.isEmpty()) { exportManager.setGamesToExport(gamesList); - exportManager.setTargetDirectory(exportSelectionDialog.getTargetDirectory(), - exportSelectionDialog.deleteBeforeExport()); + exportManager.setDeleteBeforeExport(exportSelectionDialog.deleteBeforeExport()); + exportManager.setTargetDirectory(exportSelectionDialog.getTargetDirectory()); ImportExportProgressDialog dialog = new ImportExportProgressDialog(this.mainWindow, "Export games", false); ExportWorker worker = new ExportWorker(exportManager, dialog); worker.execute(); @@ -992,8 +992,8 @@ public class MenuManager if (!viewList.isEmpty()) { exportManager.setGameViewsToExport(viewList); - exportManager.setTargetDirectory(exportSelectionDialog.getTargetDirectory(), - exportSelectionDialog.deleteBeforeExport()); + exportManager.setDeleteBeforeExport(exportSelectionDialog.deleteBeforeExport()); + exportManager.setTargetDirectory(exportSelectionDialog.getTargetDirectory()); ImportExportProgressDialog dialog = new ImportExportProgressDialog(this.mainWindow, "Export games", false); ExportFileLoaderWorker worker = new ExportFileLoaderWorker(exportManager, dialog); worker.execute(); @@ -1006,8 +1006,8 @@ public class MenuManager if (!gamesList.isEmpty()) { exportManager.setGamesToExport(gamesList); - exportManager.setTargetDirectory(exportSelectionDialog.getTargetDirectory(), - exportSelectionDialog.deleteBeforeExport()); + exportManager.setDeleteBeforeExport(exportSelectionDialog.deleteBeforeExport()); + exportManager.setTargetDirectory(exportSelectionDialog.getTargetDirectory()); ImportExportProgressDialog dialog = new ImportExportProgressDialog(this.mainWindow, "Export games", false); ExportFileLoaderWorker worker = new ExportFileLoaderWorker(exportManager, dialog); worker.execute(); diff --git a/src/main/java/se/lantz/gui/exports/ExportFileLoaderWorker.java b/src/main/java/se/lantz/gui/exports/ExportFileLoaderWorker.java index b209057..7e19148 100644 --- a/src/main/java/se/lantz/gui/exports/ExportFileLoaderWorker.java +++ b/src/main/java/se/lantz/gui/exports/ExportFileLoaderWorker.java @@ -24,8 +24,10 @@ public class ExportFileLoaderWorker extends SwingWorker { if (exportManager.isDeleteBeforeExport()) { - publish("Deleting existing games before exporting.\n"); + publish("Deleting existing games before exporting...\n"); + exportManager.deleteBeforeExport(); } + exportManager.createDirectoriesBeforeExport(); publish("Exporting from db..."); StringBuilder infoBuilder = new StringBuilder(); exportManager.readFromDb(infoBuilder); @@ -34,7 +36,7 @@ public class ExportFileLoaderWorker extends SwingWorker infoBuilder = new StringBuilder(); exportManager.createGameInfoFiles(infoBuilder, true); publish(infoBuilder.toString()); - publish("Copy game files..."); + publish("Copying game files..."); infoBuilder = new StringBuilder(); exportManager.copyGamesForFileLoader(infoBuilder); publish(infoBuilder.toString()); diff --git a/src/main/java/se/lantz/gui/exports/ExportWorker.java b/src/main/java/se/lantz/gui/exports/ExportWorker.java index eef18a8..abb2123 100644 --- a/src/main/java/se/lantz/gui/exports/ExportWorker.java +++ b/src/main/java/se/lantz/gui/exports/ExportWorker.java @@ -24,8 +24,10 @@ public class ExportWorker extends SwingWorker { if (exportManager.isDeleteBeforeExport()) { - publish("Deleting existing games before exporting.\n"); + publish("Deleting existing games before exporting...\n"); + exportManager.deleteBeforeExport(); } + exportManager.createDirectoriesBeforeExport(); publish("Exporting from db..."); StringBuilder infoBuilder = new StringBuilder(); exportManager.readFromDb(infoBuilder); @@ -34,7 +36,7 @@ public class ExportWorker extends SwingWorker infoBuilder = new StringBuilder(); exportManager.createGameInfoFiles(infoBuilder, false); publish(infoBuilder.toString()); - publish("Copy screenshots, covers and game files..."); + publish("Copying screenshots, covers and game files..."); infoBuilder = new StringBuilder(); exportManager.copyFilesForCarousel(infoBuilder); publish(infoBuilder.toString());