Skip to content

Commit f160f3c

Browse files
authored
Merge pull request #550 from taooceros/FixRepeatedManifestUpdate
fix unexpected Task Status
2 parents c2e8147 + e7b90b8 commit f160f3c

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

Plugins/Flow.Launcher.Plugin.PluginsManager/Languages/en.xaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
<system:String x:Key="plugin_pluginsmanager_update_title">Plugin Update</system:String>
2020
<system:String x:Key="plugin_pluginsmanager_update_exists">This plugin has an update, would you like to see it?</system:String>
2121
<system:String x:Key="plugin_pluginsmanager_update_alreadyexists">This plugin is already installed</system:String>
22+
<system:String x:Key="plugin_pluginsmanager_update_failed_title">Plugin Manifest Download Failed</system:String>
23+
<system:String x:Key="plugin_pluginsmanager_update_failed_subtitle">Please check if you can connect to github.com. This error means you may not be able to install or update plugins.</system:String>
2224

2325
<!--Controls-->
2426

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public Task InitAsync(PluginInitContext context)
3838
viewModel = new SettingsViewModel(context, Settings);
3939
contextMenu = new ContextMenu(Context);
4040
pluginManager = new PluginsManager(Context, Settings);
41-
_ = pluginManager.UpdateManifest().ContinueWith(_ =>
41+
_manifestUpdateTask = pluginManager.UpdateManifest().ContinueWith(_ =>
4242
{
4343
lastUpdateTime = DateTime.Now;
4444
}, TaskContinuationOptions.OnlyOnRanToCompletion);
@@ -50,6 +50,8 @@ public List<Result> LoadContextMenus(Result selectedResult)
5050
{
5151
return contextMenu.LoadContextMenus(selectedResult);
5252
}
53+
54+
private Task _manifestUpdateTask = Task.CompletedTask;
5355

5456
public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
5557
{
@@ -58,9 +60,9 @@ public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
5860
if (string.IsNullOrWhiteSpace(search))
5961
return pluginManager.GetDefaultHotKeys();
6062

61-
if ((DateTime.Now - lastUpdateTime).TotalHours > 12) // 12 hours
63+
if ((DateTime.Now - lastUpdateTime).TotalHours > 12 && _manifestUpdateTask.IsCompleted) // 12 hours
6264
{
63-
_ = pluginManager.UpdateManifest().ContinueWith(t =>
65+
_manifestUpdateTask = pluginManager.UpdateManifest().ContinueWith(t =>
6466
{
6567
lastUpdateTime = DateTime.Now;
6668
}, TaskContinuationOptions.OnlyOnRanToCompletion);

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,12 @@ internal Task UpdateManifest()
5959
}
6060
else
6161
{
62-
return _downloadManifestTask = pluginsManifest.DownloadManifest().ContinueWith(t =>
63-
Context.API.ShowMsg("Plugin Manifest Download Fail.",
64-
"Please check if you can connect to github.com. " +
65-
"This error means you may not be able to Install and Update Plugin.", icoPath, false),
62+
_downloadManifestTask = pluginsManifest.DownloadManifest();
63+
_downloadManifestTask.ContinueWith(_ =>
64+
Context.API.ShowMsg(Context.API.GetTranslation("plugin_pluginsmanager_update_failed_title"),
65+
Context.API.GetTranslation("plugin_pluginsmanager_update_failed_subtitle"), icoPath, false),
6666
TaskContinuationOptions.OnlyOnFaulted);
67+
return _downloadManifestTask;
6768
}
6869
}
6970

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.8.1",
9+
"Version": "1.8.2",
1010
"Language": "csharp",
1111
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
1212
"ExecuteFileName": "Flow.Launcher.Plugin.PluginsManager.dll",

0 commit comments

Comments
 (0)