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.
This commit is contained in:
lantzelot-swe 2022-01-02 18:11:35 +01:00
parent c42033719d
commit 1debbe348f
3 changed files with 16 additions and 12 deletions

View File

@ -954,8 +954,8 @@ public class MenuManager
if (!viewList.isEmpty()) if (!viewList.isEmpty())
{ {
exportManager.setGameViewsToExport(viewList); exportManager.setGameViewsToExport(viewList);
exportManager.setTargetDirectory(exportSelectionDialog.getTargetDirectory(), exportManager.setDeleteBeforeExport(exportSelectionDialog.deleteBeforeExport());
exportSelectionDialog.deleteBeforeExport()); exportManager.setTargetDirectory(exportSelectionDialog.getTargetDirectory());
ImportExportProgressDialog dialog = new ImportExportProgressDialog(this.mainWindow, "Export games", false); ImportExportProgressDialog dialog = new ImportExportProgressDialog(this.mainWindow, "Export games", false);
ExportWorker worker = new ExportWorker(exportManager, dialog); ExportWorker worker = new ExportWorker(exportManager, dialog);
worker.execute(); worker.execute();
@ -968,8 +968,8 @@ public class MenuManager
if (!gamesList.isEmpty()) if (!gamesList.isEmpty())
{ {
exportManager.setGamesToExport(gamesList); exportManager.setGamesToExport(gamesList);
exportManager.setTargetDirectory(exportSelectionDialog.getTargetDirectory(), exportManager.setDeleteBeforeExport(exportSelectionDialog.deleteBeforeExport());
exportSelectionDialog.deleteBeforeExport()); exportManager.setTargetDirectory(exportSelectionDialog.getTargetDirectory());
ImportExportProgressDialog dialog = new ImportExportProgressDialog(this.mainWindow, "Export games", false); ImportExportProgressDialog dialog = new ImportExportProgressDialog(this.mainWindow, "Export games", false);
ExportWorker worker = new ExportWorker(exportManager, dialog); ExportWorker worker = new ExportWorker(exportManager, dialog);
worker.execute(); worker.execute();
@ -992,8 +992,8 @@ public class MenuManager
if (!viewList.isEmpty()) if (!viewList.isEmpty())
{ {
exportManager.setGameViewsToExport(viewList); exportManager.setGameViewsToExport(viewList);
exportManager.setTargetDirectory(exportSelectionDialog.getTargetDirectory(), exportManager.setDeleteBeforeExport(exportSelectionDialog.deleteBeforeExport());
exportSelectionDialog.deleteBeforeExport()); exportManager.setTargetDirectory(exportSelectionDialog.getTargetDirectory());
ImportExportProgressDialog dialog = new ImportExportProgressDialog(this.mainWindow, "Export games", false); ImportExportProgressDialog dialog = new ImportExportProgressDialog(this.mainWindow, "Export games", false);
ExportFileLoaderWorker worker = new ExportFileLoaderWorker(exportManager, dialog); ExportFileLoaderWorker worker = new ExportFileLoaderWorker(exportManager, dialog);
worker.execute(); worker.execute();
@ -1006,8 +1006,8 @@ public class MenuManager
if (!gamesList.isEmpty()) if (!gamesList.isEmpty())
{ {
exportManager.setGamesToExport(gamesList); exportManager.setGamesToExport(gamesList);
exportManager.setTargetDirectory(exportSelectionDialog.getTargetDirectory(), exportManager.setDeleteBeforeExport(exportSelectionDialog.deleteBeforeExport());
exportSelectionDialog.deleteBeforeExport()); exportManager.setTargetDirectory(exportSelectionDialog.getTargetDirectory());
ImportExportProgressDialog dialog = new ImportExportProgressDialog(this.mainWindow, "Export games", false); ImportExportProgressDialog dialog = new ImportExportProgressDialog(this.mainWindow, "Export games", false);
ExportFileLoaderWorker worker = new ExportFileLoaderWorker(exportManager, dialog); ExportFileLoaderWorker worker = new ExportFileLoaderWorker(exportManager, dialog);
worker.execute(); worker.execute();

View File

@ -24,8 +24,10 @@ public class ExportFileLoaderWorker extends SwingWorker<Void, String>
{ {
if (exportManager.isDeleteBeforeExport()) 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..."); publish("Exporting from db...");
StringBuilder infoBuilder = new StringBuilder(); StringBuilder infoBuilder = new StringBuilder();
exportManager.readFromDb(infoBuilder); exportManager.readFromDb(infoBuilder);
@ -34,7 +36,7 @@ public class ExportFileLoaderWorker extends SwingWorker<Void, String>
infoBuilder = new StringBuilder(); infoBuilder = new StringBuilder();
exportManager.createGameInfoFiles(infoBuilder, true); exportManager.createGameInfoFiles(infoBuilder, true);
publish(infoBuilder.toString()); publish(infoBuilder.toString());
publish("Copy game files..."); publish("Copying game files...");
infoBuilder = new StringBuilder(); infoBuilder = new StringBuilder();
exportManager.copyGamesForFileLoader(infoBuilder); exportManager.copyGamesForFileLoader(infoBuilder);
publish(infoBuilder.toString()); publish(infoBuilder.toString());

View File

@ -24,8 +24,10 @@ public class ExportWorker extends SwingWorker<Void, String>
{ {
if (exportManager.isDeleteBeforeExport()) 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..."); publish("Exporting from db...");
StringBuilder infoBuilder = new StringBuilder(); StringBuilder infoBuilder = new StringBuilder();
exportManager.readFromDb(infoBuilder); exportManager.readFromDb(infoBuilder);
@ -34,7 +36,7 @@ public class ExportWorker extends SwingWorker<Void, String>
infoBuilder = new StringBuilder(); infoBuilder = new StringBuilder();
exportManager.createGameInfoFiles(infoBuilder, false); exportManager.createGameInfoFiles(infoBuilder, false);
publish(infoBuilder.toString()); publish(infoBuilder.toString());
publish("Copy screenshots, covers and game files..."); publish("Copying screenshots, covers and game files...");
infoBuilder = new StringBuilder(); infoBuilder = new StringBuilder();
exportManager.copyFilesForCarousel(infoBuilder); exportManager.copyFilesForCarousel(infoBuilder);
publish(infoBuilder.toString()); publish(infoBuilder.toString());