|
1 | | -using System; |
| 1 | +using System; |
2 | 2 | using System.Collections.Concurrent; |
3 | 3 | using System.Collections.Generic; |
4 | 4 | using System.Collections.Specialized; |
@@ -74,7 +74,6 @@ public void ChangeQuery(string query, bool requery = false) |
74 | 74 | _mainVM.ChangeQueryText(query, requery); |
75 | 75 | } |
76 | 76 |
|
77 | | - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "VSTHRD100:Avoid async void methods", Justification = "<Pending>")] |
78 | 77 | public void RestartApp() |
79 | 78 | { |
80 | 79 | _mainVM.Hide(); |
@@ -179,7 +178,7 @@ public async void CopyToClipboard(string stringToCopy, bool directCopy = false, |
179 | 178 |
|
180 | 179 | Clipboard.SetFileDropList(paths); |
181 | 180 | }); |
182 | | - |
| 181 | + |
183 | 182 | if (exception == null) |
184 | 183 | { |
185 | 184 | if (showDefaultNotification) |
@@ -218,7 +217,7 @@ public async void CopyToClipboard(string stringToCopy, bool directCopy = false, |
218 | 217 | { |
219 | 218 | LogException(nameof(PublicAPIInstance), "Failed to copy text to clipboard", exception); |
220 | 219 | ShowMsgError(GetTranslation("failedToCopy")); |
221 | | - } |
| 220 | + } |
222 | 221 | } |
223 | 222 | } |
224 | 223 |
|
@@ -327,7 +326,7 @@ public void SavePluginSettings() |
327 | 326 |
|
328 | 327 | ((PluginJsonStorage<T>)_pluginJsonStorages[type]).Save(); |
329 | 328 | } |
330 | | - |
| 329 | + |
331 | 330 | public void OpenDirectory(string directoryPath, string fileNameOrFilePath = null) |
332 | 331 | { |
333 | 332 | try |
@@ -412,6 +411,12 @@ public void OpenDirectory(string directoryPath, string fileNameOrFilePath = null |
412 | 411 |
|
413 | 412 | private void OpenUri(Uri uri, bool? inPrivate = null, bool forceBrowser = false) |
414 | 413 | { |
| 414 | + if (uri.IsFile && !FilesFolders.FileOrLocationExists(uri.LocalPath)) |
| 415 | + { |
| 416 | + ShowMsgError(GetTranslation("errorTitle"), string.Format(GetTranslation("fileNotFoundError"), uri.LocalPath)); |
| 417 | + return; |
| 418 | + } |
| 419 | + |
415 | 420 | if (forceBrowser || uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps) |
416 | 421 | { |
417 | 422 | var browserInfo = _settings.CustomBrowser; |
@@ -441,13 +446,19 @@ private void OpenUri(Uri uri, bool? inPrivate = null, bool forceBrowser = false) |
441 | 446 | } |
442 | 447 | else |
443 | 448 | { |
444 | | - Process.Start(new ProcessStartInfo() |
| 449 | + try |
445 | 450 | { |
446 | | - FileName = uri.AbsoluteUri, |
447 | | - UseShellExecute = true |
448 | | - })?.Dispose(); |
449 | | - |
450 | | - return; |
| 451 | + Process.Start(new ProcessStartInfo() |
| 452 | + { |
| 453 | + FileName = uri.AbsoluteUri, |
| 454 | + UseShellExecute = true |
| 455 | + })?.Dispose(); |
| 456 | + } |
| 457 | + catch (Exception e) |
| 458 | + { |
| 459 | + LogException(ClassName, $"Failed to open: {uri.AbsoluteUri}", e); |
| 460 | + ShowMsgError(GetTranslation("errorTitle"), e.Message); |
| 461 | + } |
451 | 462 | } |
452 | 463 | } |
453 | 464 |
|
@@ -481,7 +492,7 @@ public void OpenAppUri(Uri appUri) |
481 | 492 | OpenUri(appUri); |
482 | 493 | } |
483 | 494 |
|
484 | | - public void ToggleGameMode() |
| 495 | + public void ToggleGameMode() |
485 | 496 | { |
486 | 497 | _mainVM.ToggleGameMode(); |
487 | 498 | } |
|
0 commit comments