Don't crash if UserSelectedRecord.json can not be updated (#11789)

This commit is contained in:
Mykhailo Pylyp 2021-06-18 13:38:23 +03:00 committed by GitHub
parent 735accc1a8
commit c953f10c21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -169,9 +169,24 @@ namespace PowerLauncher.ViewModel
{
// todo: revert _userSelectedRecordStorage.Save() and _historyItemsStorage.Save() after https://github.com/microsoft/PowerToys/issues/9164 is done
_userSelectedRecord.Add(result);
_userSelectedRecordStorage.Save();
try
{
_userSelectedRecordStorage.Save();
}
catch (UnauthorizedAccessException ex)
{
Log.Warn($"Failed to save file. ${ex.Message}", this.GetType());
}
_history.Add(result.OriginQuery.RawQuery);
_historyItemsStorage.Save();
try
{
_historyItemsStorage.Save();
}
catch (UnauthorizedAccessException ex)
{
Log.Warn($"Failed to save file. ${ex.Message}", this.GetType());
}
}
else
{