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

Fix crash with DLC disabled by Steam #4002

Merged
merged 1 commit into from
Jan 18, 2024

Conversation

HebaruSan
Copy link
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 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
8 checks passed
@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 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