From 30b7c61f2444f3caada72318ff8627564cc46e00 Mon Sep 17 00:00:00 2001 From: James Clarke Date: Thu, 22 Feb 2024 10:23:25 +0000 Subject: [PATCH] Provide compatibility for backups pre-6.9 --- docs/source/release/v6.9.0/mantidworkbench.rst | 2 +- .../projectrecovery/projectrecoveryloader.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/docs/source/release/v6.9.0/mantidworkbench.rst b/docs/source/release/v6.9.0/mantidworkbench.rst index 9c87df350020..c4890b366ce9 100644 --- a/docs/source/release/v6.9.0/mantidworkbench.rst +++ b/docs/source/release/v6.9.0/mantidworkbench.rst @@ -12,7 +12,7 @@ New Features - Editing a plot's title will now automatically update its name in the plot selector (and vice versa). - Monitor for external changes to script files that are open in Mantid to prevent loss of work. - An email is now required to submit an error report. -- Project recovery performance has been improved by saving one python file for all workspaces, rather than one python file per workspace. Caution: recovering a backup by opening 6.9.0 after a crash in 6.8.0 or earlier will not work. +- Project recovery performance has been improved by saving one python file for all workspaces, rather than one python file per workspace. Bugfixes diff --git a/qt/applications/workbench/workbench/projectrecovery/projectrecoveryloader.py b/qt/applications/workbench/workbench/projectrecovery/projectrecoveryloader.py index b14f93c99716..1385860bf438 100644 --- a/qt/applications/workbench/workbench/projectrecovery/projectrecoveryloader.py +++ b/qt/applications/workbench/workbench/projectrecovery/projectrecoveryloader.py @@ -11,6 +11,7 @@ from qtpy.QtWidgets import QApplication +from mantid.api import AlgorithmManager from mantid.kernel import logger from mantidqt.project.projectloader import ProjectLoader from workbench.projectrecovery.recoverygui.projectrecoverypresenter import ProjectRecoveryPresenter @@ -98,9 +99,22 @@ def _copy_in_recovery_script(self, directory): :param directory: String; The directory in which the load_workspaces.py files exists """ saved_recovery_script = os.path.join(directory, "load_workspaces.py") + if os.path.exists(saved_recovery_script): with open(saved_recovery_script, "r") as reader, open(self.pr.recovery_order_workspace_history_file, "w") as writer: writer.write(reader.read()) + elif os.path.exists(directory): + # This is to ensure compatibility with backups from version 6.8 and earlier. + # Prior to 6.9, one python file would be saved for each workspace in the ADS. + alg_name = "OrderWorkspaceHistory" + alg = AlgorithmManager.createUnmanaged(alg_name, 1) + alg.initialize() + alg.setChild(True) + alg.setLogging(False) + alg.setRethrows(False) + alg.setProperty("RecoveryCheckpointFolder", directory) + alg.setProperty("OutputFilePath", self.pr.recovery_order_workspace_history_file) + alg.execute() self.multi_file_interpreter.mark_file_change_as_ours(self.pr.recovery_order_workspace_history_file)