From a81f27125dcf184ffed3f4c08aa83a3deb8b2f55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malte=20K=C3=B6gel?= <koegel@vr.rwth-aachen.de> Date: Wed, 11 Oct 2023 12:24:46 +0200 Subject: [PATCH] Reworked backup file structure, now also back-up (and clear) StudyRuns folder, when study is restarted --- .../StudyFrameworkPlugin/Private/SFParticipant.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Source/StudyFrameworkPlugin/Private/SFParticipant.cpp b/Source/StudyFrameworkPlugin/Private/SFParticipant.cpp index b567717..c6fc0c8 100644 --- a/Source/StudyFrameworkPlugin/Private/SFParticipant.cpp +++ b/Source/StudyFrameworkPlugin/Private/SFParticipant.cpp @@ -705,6 +705,8 @@ void USFParticipant::CreateLongTableBackUp(const FString PathToSrcFile) const void USFParticipant::ClearLogData(ASFStudySetup* StudySetup) { const FString LongTableFolder = FPaths::ProjectDir() + "StudyFramework/StudyLogs/"; + const FString StudyRunsFolder = FPaths::ProjectDir() + "StudyFramework/StudyRuns"; + const FString RecyclingBinFolder = FPaths::ProjectDir() + "StudyFramework/RecyclingBin/"; const FString Extension = "*.csv"; const FString SearchPattern = LongTableFolder + Extension; const TArray<FString> LogSubfolders = {"ParticipantLogs", "GazeTrackingLogs", "PositionLogs"}; @@ -712,20 +714,24 @@ void USFParticipant::ClearLogData(ASFStudySetup* StudySetup) IFileManager& FileManager = IFileManager::Get(); FileManager.FindFiles(FileNames, *SearchPattern, true, false); //Instead of actually deleting files, we want to move them to a recycling bin folder, to minimize risk of data loss - FString NewParentFolderPath = LongTableFolder + "RecyclingBin/" + "RestartStudyBackup-" + FDateTime::Now().ToString() + "/"; + FString NewParentFolderPath = RecyclingBinFolder + "RestartStudyBackup-" + FDateTime::Now().ToString() + "/"; //Move PhaseTables (.csv-files) for (FString Filename : FileNames) { const FString FullName = LongTableFolder + Filename; - FileManager.Move(*(NewParentFolderPath + Filename), *FullName); + FileManager.Move(*(NewParentFolderPath + "StudyLogs/" + Filename), *FullName); } //Move execution-based log folders (PositionLogs, etc.) for (FString Subfolder : LogSubfolders) { const FString FullName = LongTableFolder + Subfolder; if (FileManager.DirectoryExists(*FullName)) { - FileManager.Move(*(NewParentFolderPath + Subfolder), *FullName); + FileManager.Move(*(NewParentFolderPath + "StudyLogs/" + Subfolder), *FullName); } } + //Move StudyFramework/StudyRuns folder + if (FileManager.DirectoryExists(*StudyRunsFolder)) { + FileManager.Move(*(NewParentFolderPath + "StudyRuns"), *StudyRunsFolder); + } FSFLoggingUtils::Log("Moved .csv files: " + NewParentFolderPath); } -- GitLab