From 23283974a0bf15b717f0c97960943fb5f33f8dbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20M=C3=BCller?= Date: Wed, 17 Apr 2024 12:14:54 +0200 Subject: [PATCH] enh: warn user when source and target directory are identical (close #28) --- CHANGELOG | 1 + mpl_data_cast/gui/main.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 60c7b61..2546654 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,6 @@ 0.6.3 - fix: cleanup temporary directories on startup (#29) + - enh: warn user when source and target directory are identical (#28) 0.6.2 - setup: bump dclab from 0.55.7 to 0.57.0 0.6.1 diff --git a/mpl_data_cast/gui/main.py b/mpl_data_cast/gui/main.py index 439b832..31f30c4 100644 --- a/mpl_data_cast/gui/main.py +++ b/mpl_data_cast/gui/main.py @@ -150,6 +150,21 @@ def on_task_transfer(self) -> None: "Output directory error", "Output directory does not exist!") + # Warn the user when input and output directories are identical. + if self.widget_input.path.samefile(self.widget_output.path): + ret = QtWidgets.QMessageBox.question( + self, + "Output and input directories are identical", + "You have selected an output directory that is identical to " + "the input directory. If you continue, then the files in this " + "directory will be replaced according to the recipe " + "you chose.

" + "Are you absolutely sure you would like to continue?" + ) + if ret != QtWidgets.QMessageBox.StandardButton.Yes: + # Abort + return + self.pushButton_transfer.setEnabled(False) rp = self.current_recipe(self.widget_input.path, self.widget_output.path)