optimization: Load application metadata only for applications with IDs
This commit is contained in:
parent
6ce49a2dc7
commit
bcfe4f6b8a
1 changed files with 27 additions and 22 deletions
|
@ -422,35 +422,40 @@ namespace Ryujinx.UI.App.Common
|
||||||
|
|
||||||
foreach (var data in applications)
|
foreach (var data in applications)
|
||||||
{
|
{
|
||||||
ApplicationMetadata appMetadata = LoadAndSaveMetaData(data.IdString, appMetadata =>
|
// Only load metadata for applications with an ID
|
||||||
|
if (data.Id != 0)
|
||||||
{
|
{
|
||||||
appMetadata.Title = data.Name;
|
ApplicationMetadata appMetadata = LoadAndSaveMetaData(data.IdString, appMetadata =>
|
||||||
|
|
||||||
// Only do the migration if time_played has a value and timespan_played hasn't been updated yet.
|
|
||||||
if (appMetadata.TimePlayedOld != default && appMetadata.TimePlayed == TimeSpan.Zero)
|
|
||||||
{
|
{
|
||||||
appMetadata.TimePlayed = TimeSpan.FromSeconds(appMetadata.TimePlayedOld);
|
appMetadata.Title = data.Name;
|
||||||
appMetadata.TimePlayedOld = default;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only do the migration if last_played has a value and last_played_utc doesn't exist yet.
|
// Only do the migration if time_played has a value and timespan_played hasn't been updated yet.
|
||||||
if (appMetadata.LastPlayedOld != default && !appMetadata.LastPlayed.HasValue)
|
if (appMetadata.TimePlayedOld != default && appMetadata.TimePlayed == TimeSpan.Zero)
|
||||||
{
|
|
||||||
// Migrate from string-based last_played to DateTime-based last_played_utc.
|
|
||||||
if (DateTime.TryParse(appMetadata.LastPlayedOld, out DateTime lastPlayedOldParsed))
|
|
||||||
{
|
{
|
||||||
appMetadata.LastPlayed = lastPlayedOldParsed;
|
appMetadata.TimePlayed = TimeSpan.FromSeconds(appMetadata.TimePlayedOld);
|
||||||
|
appMetadata.TimePlayedOld = default;
|
||||||
// Migration successful: deleting last_played from the metadata file.
|
|
||||||
appMetadata.LastPlayedOld = default;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
// Only do the migration if last_played has a value and last_played_utc doesn't exist yet.
|
||||||
});
|
if (appMetadata.LastPlayedOld != default && !appMetadata.LastPlayed.HasValue)
|
||||||
|
{
|
||||||
|
// Migrate from string-based last_played to DateTime-based last_played_utc.
|
||||||
|
if (DateTime.TryParse(appMetadata.LastPlayedOld, out DateTime lastPlayedOldParsed))
|
||||||
|
{
|
||||||
|
appMetadata.LastPlayed = lastPlayedOldParsed;
|
||||||
|
|
||||||
|
// Migration successful: deleting last_played from the metadata file.
|
||||||
|
appMetadata.LastPlayedOld = default;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
data.Favorite = appMetadata.Favorite;
|
||||||
|
data.TimePlayed = appMetadata.TimePlayed;
|
||||||
|
data.LastPlayed = appMetadata.LastPlayed;
|
||||||
|
}
|
||||||
|
|
||||||
data.Favorite = appMetadata.Favorite;
|
|
||||||
data.TimePlayed = appMetadata.TimePlayed;
|
|
||||||
data.LastPlayed = appMetadata.LastPlayed;
|
|
||||||
data.FileExtension = Path.GetExtension(applicationPath).TrimStart('.').ToUpper();
|
data.FileExtension = Path.GetExtension(applicationPath).TrimStart('.').ToUpper();
|
||||||
data.FileSize = fileSize;
|
data.FileSize = fileSize;
|
||||||
data.Path = applicationPath;
|
data.Path = applicationPath;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue