0
0
Fork 0
mirror of https://github.com/ryujinx-mirror/ryujinx.git synced 2024-12-22 23:05:46 +00:00

Include content data foreach-loop in try-catch (#7036)

This commit is contained in:
TSRBerry 2024-07-18 00:02:20 +02:00 committed by GitHub
parent 6fbf279fac
commit f77bebac80
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -175,6 +175,8 @@ namespace Ryujinx.UI.App.Common
var applications = new List<ApplicationData>(); var applications = new List<ApplicationData>();
string extension = Path.GetExtension(filePath).ToLower(); string extension = Path.GetExtension(filePath).ToLower();
try
{
foreach ((ulong titleId, ContentMetaData content) in pfs.GetContentData(ContentMetaType.Application, _virtualFileSystem, _checkLevel)) foreach ((ulong titleId, ContentMetaData content) in pfs.GetContentData(ContentMetaType.Application, _virtualFileSystem, _checkLevel))
{ {
ApplicationData applicationData = new() ApplicationData applicationData = new()
@ -183,14 +185,12 @@ namespace Ryujinx.UI.App.Common
Path = filePath, Path = filePath,
}; };
try
{
Nca mainNca = content.GetNcaByType(_virtualFileSystem.KeySet, ContentType.Program); Nca mainNca = content.GetNcaByType(_virtualFileSystem.KeySet, ContentType.Program);
Nca controlNca = content.GetNcaByType(_virtualFileSystem.KeySet, ContentType.Control); Nca controlNca = content.GetNcaByType(_virtualFileSystem.KeySet, ContentType.Control);
BlitStruct<ApplicationControlProperty> controlHolder = new(1); BlitStruct<ApplicationControlProperty> controlHolder = new(1);
IFileSystem controlFs = controlNca?.OpenFileSystem(NcaSectionType.Data, IntegrityCheckLevel.None); IFileSystem controlFs = controlNca?.OpenFileSystem(NcaSectionType.Data, _checkLevel);
// Check if there is an update available. // Check if there is an update available.
if (IsUpdateApplied(mainNca, out IFileSystem updatedControlFs)) if (IsUpdateApplied(mainNca, out IFileSystem updatedControlFs))
@ -199,6 +199,11 @@ namespace Ryujinx.UI.App.Common
controlFs = updatedControlFs; controlFs = updatedControlFs;
} }
if (controlFs == null)
{
continue;
}
ReadControlData(controlFs, controlHolder.ByteSpan); ReadControlData(controlFs, controlHolder.ByteSpan);
GetApplicationInformation(ref controlHolder.Value, ref applicationData); GetApplicationInformation(ref controlHolder.Value, ref applicationData);
@ -246,23 +251,19 @@ namespace Ryujinx.UI.App.Common
applications.Add(applicationData); applications.Add(applicationData);
} }
}
catch (MissingKeyException exception) catch (MissingKeyException exception)
{ {
applicationData.Icon = extension == ".xci" ? _xciIcon : _nspIcon;
Logger.Warning?.Print(LogClass.Application, $"Your key set is missing a key with the name: {exception.Name}"); Logger.Warning?.Print(LogClass.Application, $"Your key set is missing a key with the name: {exception.Name}");
} }
catch (InvalidDataException) catch (InvalidDataException)
{ {
applicationData.Icon = extension == ".xci" ? _xciIcon : _nspIcon;
Logger.Warning?.Print(LogClass.Application, $"The header key is incorrect or missing and therefore the NCA header content type check has failed. Errored File: {filePath}"); Logger.Warning?.Print(LogClass.Application, $"The header key is incorrect or missing and therefore the NCA header content type check has failed. Errored File: {filePath}");
} }
catch (Exception exception) catch (Exception exception)
{ {
Logger.Warning?.Print(LogClass.Application, $"The file encountered was not of a valid type. File: '{filePath}' Error: {exception}"); Logger.Warning?.Print(LogClass.Application, $"The file encountered was not of a valid type. File: '{filePath}' Error: {exception}");
} }
}
return applications; return applications;
} }