Skip to content

Fix crash with DLC disabled by Steam#4002

Merged
HebaruSan merged 1 commit into
KSP-CKAN:masterfrom
HebaruSan:fix/dlc-detector-nre
Jan 18, 2024
Merged

Fix crash with DLC disabled by Steam#4002
HebaruSan merged 1 commit into
KSP-CKAN:masterfrom
HebaruSan:fix/dlc-detector-nre

Conversation

@HebaruSan
Copy link
Copy Markdown
Member

Problem

If you disable a DLC in Steam:

image

... then CKAN throws an exception when it tries to refresh:

Scanning for DLCs and manually installed modules...
Object reference not set to an instance of an object.
Repository update failed!

Cause

Steam apparently deletes the files for that DLC but leaves behind all the folders:

image

This eventually makes our DictionaryEquals extension try to call null.Equals():

System.NullReferenceException: Object reference not set to an instance of an object.
   at CKAN.Extensions.DictionaryExtensions.<>c__DisplayClass0_0`2.<DictionaryEquals>b__1(K k)
   at System.Linq.Enumerable.All[TSource](IEnumerable`1 source, Func`2 predicate)
   at CKAN.Registry.SetDlcs(Dictionary`2 dlcs)
   at CKAN.RegistryManager.ScanUnmanagedFiles()
   at CKAN.GUI.Main.UpdateRepo(Object sender, DoWorkEventArgs e)
   at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)
   at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)

Changes

  • Now the DictionaryEquals extension uses EqualityComparer<V>.Default.Equals for better null handling
  • Now the DLC detector returns false if the readme file doesn't exist, so DLCs disabled by Steam will be considered not installed

Fixes #4000.

@HebaruSan HebaruSan added Bug Something is not working as intended Core (ckan.dll) Issues affecting the core part of CKAN labels Jan 18, 2024
@HebaruSan HebaruSan merged commit 324b5f6 into KSP-CKAN:master Jan 18, 2024
@HebaruSan HebaruSan deleted the fix/dlc-detector-nre branch January 18, 2024 01:14
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: NRE, Repository update failed

1 participant