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
This commit is contained in:
ryanbodrug-microsoft 2020-06-18 07:45:40 -07:00
parent d2c1be5c2d
commit f5baa56e05

View File

@ -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);