@@ -24,7 +24,6 @@ typedef struct
24
24
Data::SaveDataType SaveType;
25
25
const Data::TitleData *TargetTitle;
26
26
BackupMenuState *CallingState = nullptr ;
27
- uint32_t UniqueID = 0 ;
28
27
} TargetStruct;
29
28
30
29
// Declarations. Definitions after class members.
@@ -124,8 +123,8 @@ void BackupMenuState::Update(void)
124
123
// Create confirmation struct.
125
124
std::shared_ptr<TargetStruct> ConfirmStruct (new TargetStruct);
126
125
ConfirmStruct->TargetPath = m_DirectoryPath / m_DirectoryListing[m_BackupMenu.GetSelected () - 1 ];
127
- ConfirmStruct->UniqueID = m_Data->GetUniqueID ();
128
126
ConfirmStruct->SaveType = m_SaveType;
127
+ ConfirmStruct->TargetTitle = m_Data;
129
128
130
129
// Query string
131
130
char TargetName[FsLib::MAX_PATH] = {0 };
@@ -204,7 +203,8 @@ static void CreateNewBackup(System::ProgressTask *Task,
204
203
BackupMenuState *CreatingState)
205
204
{
206
205
// Make sure destination exists.
207
- if (!Config::GetByKey (Config::Keys::ExportToZip) && (FsLib::DirectoryExists (BackupPath) || FsLib::CreateDirectory (BackupPath)))
206
+ if (!Config::GetByKey (Config::Keys::ExportToZip) && BackupPath.GetExtension () != u" zip" &&
207
+ (FsLib::DirectoryExists (BackupPath) || FsLib::CreateDirectory (BackupPath)))
208
208
{
209
209
// Copy save as-is to target directory.
210
210
FS::CopyDirectoryToDirectory (Task, FS::SAVE_ROOT, BackupPath, false );
@@ -275,10 +275,25 @@ static void RestoreBackup(System::ProgressTask *Task, std::shared_ptr<TargetStru
275
275
return ;
276
276
}
277
277
278
- if (! Config::GetByKey (Config::Keys::PreserveSecureValues) && ! FS::DeleteSecureValue (DataStruct-> UniqueID ))
278
+ // Secure value check. Scoped so path gets freed immediately after check is finished.
279
279
{
280
- Task->Finish ();
281
- return ;
280
+ // This is the path the secure value if it exits.
281
+ FsLib::Path SecureValuePath = DataStruct->TargetPath / u" ._secure_value" ;
282
+ if (Config::GetByKey (Config::Keys::PreserveSecureValues) && FsLib::FileExists (SecureValuePath))
283
+ {
284
+ // Try to open file and read secure value.
285
+ uint64_t SecureValue = 0 ;
286
+ FsLib::File SecureValueFile (SecureValuePath, FS_OPEN_READ);
287
+ if (!SecureValueFile.IsOpen () || SecureValueFile.Read (&SecureValue, sizeof (uint64_t )) != sizeof (uint64_t ) ||
288
+ !FsLib::SetSecureValueForTitle (DataStruct->TargetTitle ->GetUniqueID (), SecureValue))
289
+ {
290
+ Logger::Log (" Error occurred while attempting to set and preserve secure value for game." );
291
+ }
292
+ }
293
+ else if (!Config::GetByKey (Config::Keys::PreserveSecureValues) && !FS::DeleteSecureValue (DataStruct->TargetTitle ->GetUniqueID ()))
294
+ {
295
+ Logger::Log (" Error occurred while trying to delete secure value for game." );
296
+ }
282
297
}
283
298
284
299
// Whether or not committing data is needed.
0 commit comments