Skip to content

Commit 65f7745

Browse files
authored
Merge pull request #359 from Flow-Launcher/hot_fix_release
Release 1.7.2
2 parents 2af1f79 + 11675a9 commit 65f7745

File tree

12 files changed

+105
-39
lines changed

12 files changed

+105
-39
lines changed

Flow.Launcher.Core/Updater.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public async Task UpdateApp(IPublicAPI api, bool silentUpdate = true)
8787
UpdateManager.RestartApp(Constant.ApplicationFileName);
8888
}
8989
}
90-
catch (Exception e) when (e is HttpRequestException || e is WebException || e is SocketException)
90+
catch (Exception e) when (e is HttpRequestException || e is WebException || e is SocketException || e is TaskCanceledException)
9191
{
9292
Log.Exception($"|Updater.UpdateApp|Check your connection and proxy settings to github-cloud.s3.amazonaws.com.", e);
9393
api.ShowMsg(api.GetTranslation("update_flowlauncher_fail"),

Flow.Launcher.Infrastructure/Http/Http.cs

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
using System;
1010
using System.ComponentModel;
1111
using System.Threading;
12+
using System.Windows.Interop;
13+
using Flow.Launcher.Plugin;
1214

1315
namespace Flow.Launcher.Infrastructure.Http
1416
{
@@ -18,6 +20,8 @@ public static class Http
1820

1921
private static HttpClient client = new HttpClient();
2022

23+
public static IPublicAPI API { get; set; }
24+
2125
static Http()
2226
{
2327
// need to be added so it would work on a win10 machine
@@ -50,25 +54,36 @@ public static HttpProxy Proxy
5054
/// </summary>
5155
public static void UpdateProxy(ProxyProperty property)
5256
{
53-
(WebProxy.Address, WebProxy.Credentials) = property switch
57+
if (string.IsNullOrEmpty(Proxy.Server))
58+
return;
59+
60+
try
5461
{
55-
ProxyProperty.Enabled => Proxy.Enabled switch
62+
(WebProxy.Address, WebProxy.Credentials) = property switch
5663
{
57-
true => Proxy.UserName switch
64+
ProxyProperty.Enabled => Proxy.Enabled switch
5865
{
59-
var userName when !string.IsNullOrEmpty(userName) =>
60-
(new Uri($"http://{Proxy.Server}:{Proxy.Port}"), null),
61-
_ => (new Uri($"http://{Proxy.Server}:{Proxy.Port}"),
62-
new NetworkCredential(Proxy.UserName, Proxy.Password))
66+
true when !string.IsNullOrEmpty(Proxy.Server) => Proxy.UserName switch
67+
{
68+
var userName when string.IsNullOrEmpty(userName) =>
69+
(new Uri($"http://{Proxy.Server}:{Proxy.Port}"), null),
70+
_ => (new Uri($"http://{Proxy.Server}:{Proxy.Port}"),
71+
new NetworkCredential(Proxy.UserName, Proxy.Password))
72+
},
73+
_ => (null, null)
6374
},
64-
false => (null, null)
65-
},
66-
ProxyProperty.Server => (new Uri($"http://{Proxy.Server}:{Proxy.Port}"), WebProxy.Credentials),
67-
ProxyProperty.Port => (new Uri($"http://{Proxy.Server}:{Proxy.Port}"), WebProxy.Credentials),
68-
ProxyProperty.UserName => (WebProxy.Address, new NetworkCredential(Proxy.UserName, Proxy.Password)),
69-
ProxyProperty.Password => (WebProxy.Address, new NetworkCredential(Proxy.UserName, Proxy.Password)),
70-
_ => throw new ArgumentOutOfRangeException()
71-
};
75+
ProxyProperty.Server => (new Uri($"http://{Proxy.Server}:{Proxy.Port}"), WebProxy.Credentials),
76+
ProxyProperty.Port => (new Uri($"http://{Proxy.Server}:{Proxy.Port}"), WebProxy.Credentials),
77+
ProxyProperty.UserName => (WebProxy.Address, new NetworkCredential(Proxy.UserName, Proxy.Password)),
78+
ProxyProperty.Password => (WebProxy.Address, new NetworkCredential(Proxy.UserName, Proxy.Password)),
79+
_ => throw new ArgumentOutOfRangeException()
80+
};
81+
}
82+
catch(UriFormatException e)
83+
{
84+
API.ShowMsg("Please try again", "Unable to parse Http Proxy");
85+
Log.Exception("Flow.Launcher.Infrastructure.Http", "Unable to parse Uri", e);
86+
}
7287
}
7388

7489
public static async Task DownloadAsync([NotNull] string url, [NotNull] string filePath, CancellationToken token = default)

Flow.Launcher.Test/HttpTest.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using NUnit.Framework;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Text;
5+
using Flow.Launcher.Infrastructure.UserSettings;
6+
using Flow.Launcher.Infrastructure.Http;
7+
8+
namespace Flow.Launcher.Test
9+
{
10+
[TestFixture]
11+
class HttpTest
12+
{
13+
[Test]
14+
public void GivenHttpProxy_WhenUpdated_ThenWebProxyShouldAlsoBeUpdatedToTheSame()
15+
{
16+
HttpProxy proxy = new HttpProxy();
17+
Http.Proxy = proxy;
18+
19+
proxy.Enabled = true;
20+
proxy.Server = "127.0.0.1";
21+
Assert.AreEqual(Http.WebProxy.Address, new Uri($"http://{proxy.Server}:{proxy.Port}"));
22+
Assert.IsNull(Http.WebProxy.Credentials);
23+
24+
proxy.UserName = "test";
25+
Assert.NotNull(Http.WebProxy.Credentials);
26+
Assert.AreEqual(Http.WebProxy.Credentials.GetCredential(Http.WebProxy.Address, "Basic").UserName, proxy.UserName);
27+
Assert.AreEqual(Http.WebProxy.Credentials.GetCredential(Http.WebProxy.Address, "Basic").Password, "");
28+
29+
proxy.Password = "test password";
30+
Assert.AreEqual(Http.WebProxy.Credentials.GetCredential(Http.WebProxy.Address, "Basic").Password, proxy.Password);
31+
}
32+
}
33+
}

Flow.Launcher/App.xaml.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ await Stopwatch.NormalAsync("|App.OnStartup|Startup cost", async () =>
6161
_settingsVM = new SettingWindowViewModel(_updater, _portable);
6262
_settings = _settingsVM.Settings;
6363

64-
Http.Proxy = _settings.Proxy;
6564

6665
_alphabet.Initialize(_settings);
6766
_stringMatcher = new StringMatcher(_alphabet);
@@ -71,6 +70,10 @@ await Stopwatch.NormalAsync("|App.OnStartup|Startup cost", async () =>
7170
PluginManager.LoadPlugins(_settings.PluginSettings);
7271
_mainVM = new MainViewModel(_settings);
7372
API = new PublicAPIInstance(_settingsVM, _mainVM, _alphabet);
73+
74+
Http.API = API;
75+
Http.Proxy = _settings.Proxy;
76+
7477
await PluginManager.InitializePlugins(API);
7578
var window = new MainWindow(_settings, _mainVM);
7679

Flow.Launcher/ViewModel/ResultsViewModel.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
using System;
1+
using Flow.Launcher.Infrastructure.UserSettings;
2+
using Flow.Launcher.Plugin;
23
using System.Collections.Generic;
3-
using System.Collections.ObjectModel;
44
using System.Collections.Specialized;
55
using System.Linq;
66
using System.Threading;
7-
using System.Threading.Tasks;
87
using System.Windows;
98
using System.Windows.Controls;
109
using System.Windows.Data;
1110
using System.Windows.Documents;
12-
using Flow.Launcher.Infrastructure.UserSettings;
13-
using Flow.Launcher.Plugin;
1411

1512
namespace Flow.Launcher.ViewModel
1613
{

Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,24 @@ public SearchManager(Settings settings, PluginInitContext context)
2222
this.settings = settings;
2323
}
2424

25+
private class PathEqualityComparator : IEqualityComparer<Result>
26+
{
27+
private static PathEqualityComparator instance;
28+
public static PathEqualityComparator Instance => instance ??= new PathEqualityComparator();
29+
public bool Equals(Result x, Result y)
30+
{
31+
return x.SubTitle == y.SubTitle;
32+
}
33+
34+
public int GetHashCode(Result obj)
35+
{
36+
return obj.SubTitle.GetHashCode();
37+
}
38+
}
39+
2540
internal async Task<List<Result>> SearchAsync(Query query, CancellationToken token)
2641
{
27-
var results = new List<Result>();
42+
var results = new HashSet<Result>(PathEqualityComparator.Instance);
2843

2944
var querySearch = query.Search;
3045

@@ -38,7 +53,7 @@ internal async Task<List<Result>> SearchAsync(Query query, CancellationToken tok
3853
var quickaccessLinks = QuickAccess.AccessLinkListMatched(query, settings.QuickAccessLinks);
3954

4055
if (quickaccessLinks.Count > 0)
41-
results.AddRange(quickaccessLinks);
56+
results.UnionWith(quickaccessLinks);
4257

4358
var isEnvironmentVariable = EnvironmentVariables.IsEnvironmentVariableSearch(querySearch);
4459

@@ -50,9 +65,9 @@ internal async Task<List<Result>> SearchAsync(Query query, CancellationToken tok
5065

5166
if (!querySearch.IsLocationPathString() && !isEnvironmentVariablePath)
5267
{
53-
results.AddRange(await WindowsIndexFilesAndFoldersSearchAsync(query, querySearch, token).ConfigureAwait(false));
68+
results.UnionWith(await WindowsIndexFilesAndFoldersSearchAsync(query, querySearch, token).ConfigureAwait(false));
5469

55-
return results;
70+
return results.ToList();
5671
}
5772

5873
var locationPath = querySearch;
@@ -62,7 +77,7 @@ internal async Task<List<Result>> SearchAsync(Query query, CancellationToken tok
6277

6378
// Check that actual location exists, otherwise directory search will throw directory not found exception
6479
if (!FilesFolders.LocationExists(FilesFolders.ReturnPreviousDirectoryIfIncompleteString(locationPath)))
65-
return results;
80+
return results.ToList();
6681

6782
var useIndexSearch = UseWindowsIndexForDirectorySearch(locationPath);
6883

@@ -79,9 +94,9 @@ internal async Task<List<Result>> SearchAsync(Query query, CancellationToken tok
7994

8095
token.ThrowIfCancellationRequested();
8196

82-
results.AddRange(directoryResult);
97+
results.UnionWith(directoryResult);
8398

84-
return results;
99+
return results.ToList();
85100
}
86101

87102
private async Task<List<Result>> WindowsIndexFileContentSearchAsync(Query query, string querySearchString, CancellationToken token)

Plugins/Flow.Launcher.Plugin.Explorer/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"Name": "Explorer",
88
"Description": "Search and manage files and folders. Explorer utilises Windows Index Search",
99
"Author": "Jeremy Wu",
10-
"Version": "1.7.0",
10+
"Version": "1.7.1",
1111
"Language": "csharp",
1212
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
1313
"ExecuteFileName": "Flow.Launcher.Plugin.Explorer.dll",

Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ where existingPlugin.Metadata.Version.CompareTo(pluginFromManifest.Version) <
212212
Context.API.GetTranslation("plugin_pluginsmanager_update_title"),
213213
MessageBoxButton.YesNo) == MessageBoxResult.Yes)
214214
{
215-
Uninstall(x.PluginExistingMetadata);
215+
Uninstall(x.PluginExistingMetadata, false);
216216

217217
var downloadToFilePath = Path.Combine(DataLocation.PluginsDirectory,
218218
$"{x.Name}-{x.NewVersion}.zip");
@@ -399,10 +399,13 @@ internal List<Result> RequestUninstall(string search)
399399
return Search(results, uninstallSearch);
400400
}
401401

402-
private void Uninstall(PluginMetadata plugin)
402+
private void Uninstall(PluginMetadata plugin, bool removedSetting = true)
403403
{
404-
PluginManager.Settings.Plugins.Remove(plugin.ID);
405-
PluginManager.AllPlugins.RemoveAll(p => p.Metadata.ID == plugin.ID);
404+
if (removedSetting)
405+
{
406+
PluginManager.Settings.Plugins.Remove(plugin.ID);
407+
PluginManager.AllPlugins.RemoveAll(p => p.Metadata.ID == plugin.ID);
408+
}
406409

407410
// Marked for deletion. Will be deleted on next start up
408411
using var _ = File.CreateText(Path.Combine(plugin.PluginDirectory, "NeedDelete.txt"));

Plugins/Flow.Launcher.Plugin.PluginsManager/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"Name": "Plugins Manager",
77
"Description": "Management of installing, uninstalling or updating Flow Launcher plugins",
88
"Author": "Jeremy Wu",
9-
"Version": "1.6.4",
9+
"Version": "1.6.5",
1010
"Language": "csharp",
1111
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
1212
"ExecuteFileName": "Flow.Launcher.Plugin.PluginsManager.dll",

0 commit comments

Comments
 (0)