From f5baa56e0543f55098409e2076b3d11d98563666 Mon Sep 17 00:00:00 2001 From: ryanbodrug-microsoft <56318517+ryanbodrug-microsoft@users.noreply.github.com> Date: Thu, 18 Jun 2020 07:45:40 -0700 Subject: [PATCH] Fix for CA1031. Settings.json is locked by the settings application and throws a system IO Exception. This should be syncronized with the settings application, but for now I'm just fixing the exception to be more specific and not hide unexpected exceptions. System.IO.IOException: 'The process cannot access the file 'C:\Users\ryanbod\AppData\Local\Microsoft\PowerToys\PowerToys Run\settings.json' because it is being used by another process.' Severity Code Description Project File Line Suppression State Warning CA1031 Modify 'OverloadSettings' to catch a more specific allowed exception type, or rethrow the exception. PowerLauncher C:\Repos\PowerToys\src\modules\launcher\PowerLauncher\SettingsWatcher.cs 76 Active --- src/modules/launcher/PowerLauncher/SettingsWatcher.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/modules/launcher/PowerLauncher/SettingsWatcher.cs b/src/modules/launcher/PowerLauncher/SettingsWatcher.cs index 6dcdb3fdd0..b815a7c25a 100644 --- a/src/modules/launcher/PowerLauncher/SettingsWatcher.cs +++ b/src/modules/launcher/PowerLauncher/SettingsWatcher.cs @@ -73,7 +73,9 @@ namespace PowerLauncher _settings.IgnoreHotkeysOnFullscreen = overloadSettings.properties.ignore_hotkeys_in_fullscreen; } } - catch (Exception e) + // the settings application can hold a lock on the settings.json file which will result in a IOException. + // This should be changed to properly synch with the settings app instead of retrying. + catch (IOException e) { retry = true; Thread.Sleep(1000);