mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2025-01-14 22:50:34 +00:00
Adjust migration logic
Handles clean-up for an edge-case scenario that for some reason the user launches the old version of Ryujinx again and it creates the default legacy files.
This commit is contained in:
parent
8eb68aa2aa
commit
ac716fb3b8
1 changed files with 13 additions and 3 deletions
|
@ -521,12 +521,20 @@ namespace Ryujinx.Ui.App.Common
|
|||
|
||||
// Handle migration from old default to current user
|
||||
string legacyFile = Path.Combine(guiFolder, "metadata.json");
|
||||
if (File.Exists(legacyFile) && !File.Exists(metadataFile))
|
||||
if (File.Exists(legacyFile))
|
||||
{
|
||||
File.Move(legacyFile, metadataFile);
|
||||
File.Delete(legacyFile);
|
||||
if (!File.Exists(metadataFile))
|
||||
{
|
||||
File.Move(legacyFile, metadataFile);
|
||||
}
|
||||
|
||||
if (File.Exists(metadataFile))
|
||||
{
|
||||
File.Delete(legacyFile);
|
||||
}
|
||||
}
|
||||
|
||||
// Create metadata file if it doesn't exist yet
|
||||
ApplicationMetadata appMetadata;
|
||||
|
||||
if (!File.Exists(metadataFile))
|
||||
|
@ -536,6 +544,7 @@ namespace Ryujinx.Ui.App.Common
|
|||
JsonHelper.SerializeToFile(metadataFile, appMetadata, SerializerContext.ApplicationMetadata);
|
||||
}
|
||||
|
||||
// Read from the metadata file
|
||||
try
|
||||
{
|
||||
appMetadata = JsonHelper.DeserializeFromFile(metadataFile, SerializerContext.ApplicationMetadata);
|
||||
|
@ -547,6 +556,7 @@ namespace Ryujinx.Ui.App.Common
|
|||
appMetadata = new ApplicationMetadata();
|
||||
}
|
||||
|
||||
// Modify the metadata and save it back to the file
|
||||
if (modifyFunction != null)
|
||||
{
|
||||
modifyFunction(appMetadata);
|
||||
|
|
Loading…
Reference in a new issue