mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2025-01-15 07:00:32 +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
|
// Handle migration from old default to current user
|
||||||
string legacyFile = Path.Combine(guiFolder, "metadata.json");
|
string legacyFile = Path.Combine(guiFolder, "metadata.json");
|
||||||
if (File.Exists(legacyFile) && !File.Exists(metadataFile))
|
if (File.Exists(legacyFile))
|
||||||
|
{
|
||||||
|
if (!File.Exists(metadataFile))
|
||||||
{
|
{
|
||||||
File.Move(legacyFile, metadataFile);
|
File.Move(legacyFile, metadataFile);
|
||||||
File.Delete(legacyFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (File.Exists(metadataFile))
|
||||||
|
{
|
||||||
|
File.Delete(legacyFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create metadata file if it doesn't exist yet
|
||||||
ApplicationMetadata appMetadata;
|
ApplicationMetadata appMetadata;
|
||||||
|
|
||||||
if (!File.Exists(metadataFile))
|
if (!File.Exists(metadataFile))
|
||||||
|
@ -536,6 +544,7 @@ namespace Ryujinx.Ui.App.Common
|
||||||
JsonHelper.SerializeToFile(metadataFile, appMetadata, SerializerContext.ApplicationMetadata);
|
JsonHelper.SerializeToFile(metadataFile, appMetadata, SerializerContext.ApplicationMetadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Read from the metadata file
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
appMetadata = JsonHelper.DeserializeFromFile(metadataFile, SerializerContext.ApplicationMetadata);
|
appMetadata = JsonHelper.DeserializeFromFile(metadataFile, SerializerContext.ApplicationMetadata);
|
||||||
|
@ -547,6 +556,7 @@ namespace Ryujinx.Ui.App.Common
|
||||||
appMetadata = new ApplicationMetadata();
|
appMetadata = new ApplicationMetadata();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Modify the metadata and save it back to the file
|
||||||
if (modifyFunction != null)
|
if (modifyFunction != null)
|
||||||
{
|
{
|
||||||
modifyFunction(appMetadata);
|
modifyFunction(appMetadata);
|
||||||
|
|
Loading…
Reference in a new issue