Skip to content
Snippets Groups Projects
Commit 717f0d2c authored by Keith Butler's avatar Keith Butler
Browse files

Re #23248 removing un-needed sanitise checks from ProjectRecovery

parent d0264f35
No related merge requests found
......@@ -13,9 +13,7 @@
#include "MantidKernel/PropertyHistory.h"
#include <boost/algorithm/string/classification.hpp>
#include <boost/optional.hpp>
#include <boost/range/algorithm/remove_if.hpp>
#include <boost/range/algorithm_ext/erase.hpp>
#include <boost/utility.hpp>
#include <set>
......@@ -267,9 +265,6 @@ const std::string ScriptBuilder::buildPropertyString(
prop = propHistory.name() + opener + propHistory.value() + "'";
}
// Sanitise for a comment #
std::string blacklistChars{"#"};
boost::remove_erase_if(prop, boost::is_any_of(blacklistChars));
}
return prop;
......
......@@ -126,7 +126,7 @@ getRecoveryFolderCheckpoints(const std::string &recoveryFolderPath) {
std::string removeInvalidFilenameChars(std::string s) {
// NTFS is most restrictive, so blacklist on this
std::string blacklistChars{"#:*?<>|/\"\\"};
std::string blacklistChars{":*?<>|/\"\\"};
boost::remove_erase_if(s, boost::is_any_of(blacklistChars));
return s;
}
......@@ -356,17 +356,12 @@ void ProjectRecovery::loadRecoveryCheckpoint(const Poco::Path &recoveryFolder) {
auto projectFile = Poco::Path(recoveryFolder).append(OUTPUT_PROJ_NAME);
bool loadCompleted = false;
if (!isSanitised(recoveryFolder)) {
if (!QMetaObject::invokeMethod(
m_windowPtr, "loadProjectRecovery", Qt::BlockingQueuedConnection,
Q_RETURN_ARG(bool, loadCompleted),
Q_ARG(const std::string, projectFile.toString()))) {
throw std::runtime_error("Project Recovery: Failed to load project "
"windows - Qt binding failed");
}
} else {
g_log.debug("Recovered workspace name was sanitised");
loadCompleted = true;
m_windowPtr, "loadProjectRecovery", Qt::BlockingQueuedConnection,
Q_RETURN_ARG(bool, loadCompleted),
Q_ARG(const std::string, projectFile.toString()))) {
throw std::runtime_error(
"Project Recovery: Failed to load project windows - Qt binding failed");
}
if (!loadCompleted) {
......@@ -529,26 +524,4 @@ void ProjectRecovery::saveWsHistories(const Poco::Path &historyDestFolder) {
}
}
/**
* Check the OUTPUT_PROJ_NAME file for WorkspaceNames and if any of them have
* "#" then return True else False.
*
*/
bool ProjectRecovery::isSanitised(const Poco::Path &recoveryFolder) {
auto projectFile = Poco::Path(recoveryFolder).append(OUTPUT_PROJ_NAME);
std::ifstream propFile(projectFile.toString(), std::ios_base::in);
std::string processString((std::istreambuf_iterator<char>(propFile)),
std::istreambuf_iterator<char>());
propFile.close();
auto filePosition = processString.find("WorkspaceNames") + 15;
auto endOfPosition = processString.find("</mantidworkspaces>");
for (; filePosition < endOfPosition; ++filePosition) {
if (processString[filePosition] == char('#')) {
return true;
}
}
return false;
}
} // namespace MantidQt
......@@ -100,9 +100,6 @@ private:
/// Saves the current workspace's histories from Mantid
void saveWsHistories(const Poco::Path &projectDestFile);
/// Checks if the workspaces had been sanitised when saved
bool isSanitised(const Poco::Path &recoveryFolder);
/// Background thread which runs the saving body
std::thread m_backgroundSavingThread;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment