Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle missing indexes in Steam vdf file lists #4279

Merged
merged 1 commit into from
Dec 19, 2024

Conversation

HebaruSan
Copy link
Member

Problem

Steam apparently allows libraryfolders.vdf to skip indexes:

"libraryfolders"
{
	"0"
	{
		// removed data for brevity
	}
	"2"
	{
		// removed data for brevity
	}
}

But when we try to parse this as a List, an exception is thrown:

Unhandled Exception: System.InvalidOperationException: Cannot deserialize a non-array value to type "System.Collections.Generic.List`1".
   at ValveKeyValue.ObjectCopier.MakeObject[TObject](KVObject keyValueObject, IObjectReflector reflector)
   at CKAN.SteamLibrary..ctor(String libraryPath)
   at CKAN.GameInstanceManager..ctor(IUser user, IConfiguration configuration)
   at CKAN.CmdLine.MainClass.Execute(GameInstanceManager manager, CommonOptions opts, String[] args)
   at CKAN.CmdLine.MainClass.Main(String[] args)

Changes

  • Now instead of parsing this file as a list, we parse it as a dictionary and take the .Values property
  • Now these exceptions are caught, logged, and ignored so CKAN can continue loading
  • Same but for shortcuts.vdf, just in case

Fixes #4278.

@HebaruSan HebaruSan added Bug Something is not working as intended Easy This is easy to fix Core (ckan.dll) Issues affecting the core part of CKAN labels Dec 19, 2024
@HebaruSan HebaruSan merged commit 2d87f78 into KSP-CKAN:master Dec 19, 2024
3 checks passed
@HebaruSan HebaruSan deleted the fix/steam-parsing branch December 19, 2024 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is not working as intended Core (ckan.dll) Issues affecting the core part of CKAN Easy This is easy to fix
Projects
None yet
1 participant