From 4dae5f59a182ef3d55d42b8700dec6d9a20b07f3 Mon Sep 17 00:00:00 2001
From: Samuel Jones <samjones714@gmail.com>
Date: Mon, 26 Nov 2018 13:35:12 +0000
Subject: [PATCH] Re #23739 Add further sanity check and improvements

---
 MantidPlot/src/ProjectRecovery.cpp | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/MantidPlot/src/ProjectRecovery.cpp b/MantidPlot/src/ProjectRecovery.cpp
index e64cabb4f3a..e057fb18d6f 100644
--- a/MantidPlot/src/ProjectRecovery.cpp
+++ b/MantidPlot/src/ProjectRecovery.cpp
@@ -152,8 +152,8 @@ std::vector<int> orderProcessIDs(std::vector<Poco::Path> paths) {
       // The folder or file here is not a number (So shouldn't exist) so delete
       // it recursively. However perform a sanity check as recursively removing
       // files is dangerous
-      Poco::Path sanityCheckPath(getRecoveryFolderCheck());
-      if (sanityCheckPath.toString() ==
+      const auto sanityCheckPath(getRecoveryFolderCheck());
+      if (sanityCheckPath ==
           Poco::Path(c.toString()).popDirectory().toString()) {
         Poco::File(c).remove(true);
       }
@@ -807,7 +807,10 @@ void ProjectRecovery::repairCheckpointDirectory() {
 
   for (auto c : vectorToDelete) {
     // Remove c recursively
-    Poco::File(c).remove(true);
+    const auto sanityCheckPath(getRecoveryFolderCheck());
+    if (sanityCheckPath == Poco::Path(c).popDirectory().toString()) {
+      Poco::File(c).remove(true);
+    }
   }
 
   if (vectorToDelete.size() > 0) {
-- 
GitLab