Skip to content

Commit 2234ed1

Browse files
authored
Merge branch 'dev' into flow_launcher_localization
2 parents 41200b8 + 1e8819a commit 2234ed1

File tree

7 files changed

+41
-18
lines changed

7 files changed

+41
-18
lines changed

Flow.Launcher.Infrastructure/UserSettings/DataLocation.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ public static class DataLocation
77
{
88
public const string PortableFolderName = "UserData";
99
public const string DeletionIndicatorFile = ".dead";
10-
public static string PortableDataPath = Path.Combine(Constant.ProgramDirectory, PortableFolderName);
11-
public static string RoamingDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "FlowLauncher");
10+
public static readonly string PortableDataPath = Path.Combine(Constant.ProgramDirectory, PortableFolderName);
11+
public static readonly string RoamingDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "FlowLauncher");
1212
public static string DataDirectory()
1313
{
1414
if (PortableDataLocationInUse())
@@ -19,7 +19,8 @@ public static string DataDirectory()
1919

2020
public static bool PortableDataLocationInUse()
2121
{
22-
if (Directory.Exists(PortableDataPath) && !File.Exists(DeletionIndicatorFile))
22+
if (Directory.Exists(PortableDataPath) &&
23+
!File.Exists(Path.Combine(PortableDataPath, DeletionIndicatorFile)))
2324
return true;
2425

2526
return false;

Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,16 @@ public static bool FileExists(this string filePath)
150150
return File.Exists(filePath);
151151
}
152152

153+
/// <summary>
154+
/// Checks if a file or directory exists
155+
/// </summary>
156+
/// <param name="path"></param>
157+
/// <returns></returns>
158+
public static bool FileOrLocationExists(this string path)
159+
{
160+
return LocationExists(path) || FileExists(path);
161+
}
162+
153163
/// <summary>
154164
/// Open a directory window (using the OS's default handler, usually explorer)
155165
/// </summary>

Flow.Launcher/Languages/en.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,7 @@
590590
<system:String x:Key="errorTitle">Error</system:String>
591591
<system:String x:Key="folderOpenError">An error occurred while opening the folder. {0}</system:String>
592592
<system:String x:Key="browserOpenError">An error occurred while opening the URL in the browser. Please check your Default Web Browser configuration in the General section of the settings window</system:String>
593+
<system:String x:Key="fileNotFoundError">File or directory not found: {0}</system:String>
593594

594595
<!-- General Notice -->
595596
<system:String x:Key="pleaseWait">Please wait...</system:String>

Flow.Launcher/PublicAPIInstance.cs

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Concurrent;
33
using System.Collections.Generic;
44
using System.Collections.Specialized;
@@ -74,7 +74,6 @@ public void ChangeQuery(string query, bool requery = false)
7474
_mainVM.ChangeQueryText(query, requery);
7575
}
7676

77-
[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "VSTHRD100:Avoid async void methods", Justification = "<Pending>")]
7877
public void RestartApp()
7978
{
8079
_mainVM.Hide();
@@ -179,7 +178,7 @@ public async void CopyToClipboard(string stringToCopy, bool directCopy = false,
179178

180179
Clipboard.SetFileDropList(paths);
181180
});
182-
181+
183182
if (exception == null)
184183
{
185184
if (showDefaultNotification)
@@ -218,7 +217,7 @@ public async void CopyToClipboard(string stringToCopy, bool directCopy = false,
218217
{
219218
LogException(nameof(PublicAPIInstance), "Failed to copy text to clipboard", exception);
220219
ShowMsgError(GetTranslation("failedToCopy"));
221-
}
220+
}
222221
}
223222
}
224223

@@ -327,7 +326,7 @@ public void SavePluginSettings()
327326

328327
((PluginJsonStorage<T>)_pluginJsonStorages[type]).Save();
329328
}
330-
329+
331330
public void OpenDirectory(string directoryPath, string fileNameOrFilePath = null)
332331
{
333332
try
@@ -412,6 +411,12 @@ public void OpenDirectory(string directoryPath, string fileNameOrFilePath = null
412411

413412
private void OpenUri(Uri uri, bool? inPrivate = null, bool forceBrowser = false)
414413
{
414+
if (uri.IsFile && !FilesFolders.FileOrLocationExists(uri.LocalPath))
415+
{
416+
ShowMsgError(GetTranslation("errorTitle"), string.Format(GetTranslation("fileNotFoundError"), uri.LocalPath));
417+
return;
418+
}
419+
415420
if (forceBrowser || uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps)
416421
{
417422
var browserInfo = _settings.CustomBrowser;
@@ -441,13 +446,19 @@ private void OpenUri(Uri uri, bool? inPrivate = null, bool forceBrowser = false)
441446
}
442447
else
443448
{
444-
Process.Start(new ProcessStartInfo()
449+
try
445450
{
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+
}
451462
}
452463
}
453464

@@ -481,7 +492,7 @@ public void OpenAppUri(Uri appUri)
481492
OpenUri(appUri);
482493
}
483494

484-
public void ToggleGameMode()
495+
public void ToggleGameMode()
485496
{
486497
_mainVM.ToggleGameMode();
487498
}

Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public List<int> ScreenNumbers
123123
}
124124

125125
// This is only required to set at startup. When portable mode enabled/disabled a restart is always required
126-
private static bool _portableMode = DataLocation.PortableDataLocationInUse();
126+
private static readonly bool _portableMode = DataLocation.PortableDataLocationInUse();
127127

128128
public bool PortableMode
129129
{

Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<OutputType>Library</OutputType>

Plugins/Flow.Launcher.Plugin.Calculator/Flow.Launcher.Plugin.Calculator.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<OutputType>Library</OutputType>

0 commit comments

Comments
 (0)