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

Don't throw exceptions when resetting cache dir #2547

Merged
merged 1 commit into from
Oct 23, 2018

Conversation

HebaruSan
Copy link
Member

Problem

In the settings, if you click the Reset in the cache section twice, an exception occurs:

************** Tekst van uitzondering **************
System.ArgumentException: Er bestaat geen waarde met deze naam.
   bij System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   bij Microsoft.Win32.RegistryKey.DeleteValue(String name)
   bij CKAN.Win32Registry.DeleteRegistryValue(String name)
   bij CKAN.Win32Registry.set_DownloadCacheDir(String value)
   bij CKAN.KSPManager.TrySetupCache(String path, String& failureReason)
   bij CKAN.SettingsDialog.UpdateCacheInfo(String newPath)
   bij CKAN.SettingsDialog.ResetCacheButton_Click(Object sender, EventArgs e)
   bij System.Windows.Forms.Control.OnClick(EventArgs e)
   bij System.Windows.Forms.Button.OnClick(EventArgs e)
   bij System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   bij System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   bij System.Windows.Forms.Control.WndProc(Message& m)
   bij System.Windows.Forms.ButtonBase.WndProc(Message& m)
   bij System.Windows.Forms.Button.WndProc(Message& m)
   bij System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

This probably also happens if you run ckan cache reset twice.

Cause

RegistryKey.DeleteValue doesn't like it when you try to delete a value that doesn't exist.

Change

There's another version of that function that has a second parameter:

throwOnMissingValue
Boolean
Indicates whether an exception should be raised if the specified value cannot be found. If this argument is true and the specified value does not exist, an exception is raised. If this argument is false and the specified value does not exist, no action is taken.

Now we pass that as false.

Fixes #2545.

@HebaruSan HebaruSan added Bug Easy This is easy to fix GUI Issues affecting the interactive GUI Pull request labels Oct 22, 2018
@politas politas merged commit 966661f into KSP-CKAN:master Oct 23, 2018
@HebaruSan HebaruSan deleted the fix/delete-key-error branch October 23, 2018 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Easy This is easy to fix GUI Issues affecting the interactive GUI Pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants