Skip to content
Snippets Groups Projects
Commit a81f2712 authored by Malte Christian Kögel's avatar Malte Christian Kögel
Browse files

Reworked backup file structure, now also back-up (and clear) StudyRuns folder,...

Reworked backup file structure, now also back-up (and clear) StudyRuns folder, when study is restarted
parent 42f97178
No related branches found
No related tags found
No related merge requests found
...@@ -705,6 +705,8 @@ void USFParticipant::CreateLongTableBackUp(const FString PathToSrcFile) const ...@@ -705,6 +705,8 @@ void USFParticipant::CreateLongTableBackUp(const FString PathToSrcFile) const
void USFParticipant::ClearLogData(ASFStudySetup* StudySetup) void USFParticipant::ClearLogData(ASFStudySetup* StudySetup)
{ {
const FString LongTableFolder = FPaths::ProjectDir() + "StudyFramework/StudyLogs/"; 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 Extension = "*.csv";
const FString SearchPattern = LongTableFolder + Extension; const FString SearchPattern = LongTableFolder + Extension;
const TArray<FString> LogSubfolders = {"ParticipantLogs", "GazeTrackingLogs", "PositionLogs"}; const TArray<FString> LogSubfolders = {"ParticipantLogs", "GazeTrackingLogs", "PositionLogs"};
...@@ -712,20 +714,24 @@ void USFParticipant::ClearLogData(ASFStudySetup* StudySetup) ...@@ -712,20 +714,24 @@ void USFParticipant::ClearLogData(ASFStudySetup* StudySetup)
IFileManager& FileManager = IFileManager::Get(); IFileManager& FileManager = IFileManager::Get();
FileManager.FindFiles(FileNames, *SearchPattern, true, false); 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 //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) //Move PhaseTables (.csv-files)
for (FString Filename : FileNames) for (FString Filename : FileNames)
{ {
const FString FullName = LongTableFolder + Filename; const FString FullName = LongTableFolder + Filename;
FileManager.Move(*(NewParentFolderPath + Filename), *FullName); FileManager.Move(*(NewParentFolderPath + "StudyLogs/" + Filename), *FullName);
} }
//Move execution-based log folders (PositionLogs, etc.) //Move execution-based log folders (PositionLogs, etc.)
for (FString Subfolder : LogSubfolders) { for (FString Subfolder : LogSubfolders) {
const FString FullName = LongTableFolder + Subfolder; const FString FullName = LongTableFolder + Subfolder;
if (FileManager.DirectoryExists(*FullName)) { 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); FSFLoggingUtils::Log("Moved .csv files: " + NewParentFolderPath);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment