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

Also move log folders (PositionLogs, GazeTrackingLogs, ParticipantLogs) to...

Also move log folders (PositionLogs, GazeTrackingLogs, ParticipantLogs) to RecyclingBin when restarting study.
parent 1902ad19
Branches
Tags
No related merge requests found
...@@ -255,7 +255,7 @@ void USFGameInstance::PrepareWithStudySetup(ASFStudySetup* Setup) ...@@ -255,7 +255,7 @@ void USFGameInstance::PrepareWithStudySetup(ASFStudySetup* Setup)
ParticipantSequenceNumber = 0; ParticipantSequenceNumber = 0;
Conditions = StudySetup->GetAllConditionsForRun(ParticipantSequenceNumber); Conditions = StudySetup->GetAllConditionsForRun(ParticipantSequenceNumber);
//clear data //clear data
USFParticipant::ClearPhaseLongtables(Setup); USFParticipant::ClearLogData(Setup);
break; break;
case 0: case 0:
FSFLoggingUtils::Log("[USFGameInstance::PrepareWithStudySetup]: Continue last participant"); FSFLoggingUtils::Log("[USFGameInstance::PrepareWithStudySetup]: Continue last participant");
......
...@@ -702,21 +702,30 @@ void USFParticipant::CreateLongTableBackUp(const FString PathToSrcFile) const ...@@ -702,21 +702,30 @@ void USFParticipant::CreateLongTableBackUp(const FString PathToSrcFile) const
} }
void USFParticipant::ClearPhaseLongtables(ASFStudySetup* StudySetup) void USFParticipant::ClearLogData(ASFStudySetup* StudySetup)
{ {
const FString LongTableFolder = FPaths::ProjectDir() + "StudyFramework/StudyLogs/"; const FString LongTableFolder = FPaths::ProjectDir() + "StudyFramework/StudyLogs/";
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"};
TArray<FString> FileNames; TArray<FString> FileNames;
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 = LongTableFolder + "RecyclingBin/" + "RestartStudyBackup-" + FDateTime::Now().ToString() + "/";
//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 + 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);
}
}
FSFLoggingUtils::Log("Moved .csv files: " + NewParentFolderPath); FSFLoggingUtils::Log("Moved .csv files: " + NewParentFolderPath);
} }
......
...@@ -74,7 +74,7 @@ public: ...@@ -74,7 +74,7 @@ public:
// for the data to be ready to use in statistics software. This methods clears all // for the data to be ready to use in statistics software. This methods clears all
// of that data (e.g. if study is entirely restarted). // of that data (e.g. if study is entirely restarted).
// The data can be recovered from /StudyLogs/RecyclingBin // The data can be recovered from /StudyLogs/RecyclingBin
static void ClearPhaseLongtables(ASFStudySetup* StudySetup); static void ClearLogData(ASFStudySetup* StudySetup);
// Whenever we delete data in a file (e.g. with by restarting a condition), // Whenever we delete data in a file (e.g. with by restarting a condition),
// we want to create a backup, to enable data recovery // we want to create a backup, to enable data recovery
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment