Skip to content

Commit

Permalink
Merge pull request #36914 from mantidproject/project_recovery_fix
Browse files Browse the repository at this point in the history
Provide compatibility for backups pre-6.9
  • Loading branch information
thomashampson authored Feb 22, 2024
2 parents a5d17ed + 30b7c61 commit 66c74f8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/source/release/v6.9.0/mantidworkbench.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 66c74f8

Please sign in to comment.