From 8c3361d6c4da54b6f0990fc4ac1c7808342f236b Mon Sep 17 00:00:00 2001 From: Joel Puig Rubio Date: Sat, 6 Jun 2020 23:53:25 +0200 Subject: [PATCH] Abort update if the updater is found under the root path --- update_gui.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/update_gui.py b/update_gui.py index 61154fa..1c1550f 100644 --- a/update_gui.py +++ b/update_gui.py @@ -62,6 +62,11 @@ def __init__(self, server, parent=None): self.step_unit = None self.progress = 0 + if getattr(sys, 'frozen', False): + self.app_path = os.path.abspath(sys.executable) + else: + self.app_path = os.path.abspath(__file__) + self.root_path = QLineEdit() self.root_path.textChanged[str].connect(self.on_path_changed) self.browse_button = QPushButton('Browse...') @@ -178,6 +183,9 @@ def on_update_button(self): if not os.path.isdir(root_path): QMessageBox.critical(self, 'Cannot proceed', 'Please make sure that the root path exists.') return + if index.win_path(self.app_path).lower().startswith(root_path.lower()): + QMessageBox.critical(self, 'Cannot proceed', 'Flashpoint Updater is found under the root path.\nPlease move it to a different location to proceed.') + return self.update_button.setEnabled(False) current = str(self.from_combo_box.currentText()) target = str(self.to_combo_box.currentText())