mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Suppress Startup Manifest Download Error Notification
This commit is contained in:
parent
44e5e466c5
commit
5ae9ee46c0
3 changed files with 50 additions and 45 deletions
|
|
@ -31,7 +31,7 @@ namespace Flow.Launcher.Core.ExternalPlugins
|
|||
return UpdateTask = DownloadManifestAsync();
|
||||
}
|
||||
|
||||
private async static Task DownloadManifestAsync()
|
||||
private static async Task DownloadManifestAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
|
|||
|
|
@ -38,10 +38,12 @@ namespace Flow.Launcher.Plugin.PluginsManager
|
|||
viewModel = new SettingsViewModel(context, Settings);
|
||||
contextMenu = new ContextMenu(Context);
|
||||
pluginManager = new PluginsManager(Context, Settings);
|
||||
_manifestUpdateTask = pluginManager.UpdateManifestAsync().ContinueWith(_ =>
|
||||
{
|
||||
lastUpdateTime = DateTime.Now;
|
||||
}, TaskContinuationOptions.OnlyOnRanToCompletion);
|
||||
_manifestUpdateTask = pluginManager
|
||||
.UpdateManifestAsync(true)
|
||||
.ContinueWith(_ =>
|
||||
{
|
||||
lastUpdateTime = DateTime.Now;
|
||||
}, TaskContinuationOptions.OnlyOnRanToCompletion);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
|
@ -50,7 +52,7 @@ namespace Flow.Launcher.Plugin.PluginsManager
|
|||
{
|
||||
return contextMenu.LoadContextMenus(selectedResult);
|
||||
}
|
||||
|
||||
|
||||
private Task _manifestUpdateTask = Task.CompletedTask;
|
||||
|
||||
public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
|
||||
|
|
@ -72,11 +74,11 @@ namespace Flow.Launcher.Plugin.PluginsManager
|
|||
{
|
||||
//search could be url, no need ToLower() when passed in
|
||||
var s when s.StartsWith(Settings.HotKeyInstall, StringComparison.OrdinalIgnoreCase)
|
||||
=> await pluginManager.RequestInstallOrUpdate(search, token),
|
||||
=> await pluginManager.RequestInstallOrUpdate(search, token),
|
||||
var s when s.StartsWith(Settings.HotkeyUninstall, StringComparison.OrdinalIgnoreCase)
|
||||
=> pluginManager.RequestUninstall(search),
|
||||
var s when s.StartsWith(Settings.HotkeyUpdate, StringComparison.OrdinalIgnoreCase)
|
||||
=> await pluginManager.RequestUpdate(search, token),
|
||||
=> pluginManager.RequestUninstall(search),
|
||||
var s when s.StartsWith(Settings.HotkeyUpdate, StringComparison.OrdinalIgnoreCase)
|
||||
=> await pluginManager.RequestUpdate(search, token),
|
||||
_ => pluginManager.GetDefaultHotKeys().Where(hotkey =>
|
||||
{
|
||||
hotkey.Score = StringMatcher.FuzzySearch(search, hotkey.Title).Score;
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ namespace Flow.Launcher.Plugin.PluginsManager
|
|||
|
||||
private Task _downloadManifestTask = Task.CompletedTask;
|
||||
|
||||
internal Task UpdateManifestAsync()
|
||||
internal Task UpdateManifestAsync(bool silent = false)
|
||||
{
|
||||
if (_downloadManifestTask.Status == TaskStatus.Running)
|
||||
{
|
||||
|
|
@ -60,10 +60,11 @@ namespace Flow.Launcher.Plugin.PluginsManager
|
|||
else
|
||||
{
|
||||
_downloadManifestTask = PluginsManifest.UpdateTask;
|
||||
_downloadManifestTask.ContinueWith(_ =>
|
||||
Context.API.ShowMsg(Context.API.GetTranslation("plugin_pluginsmanager_update_failed_title"),
|
||||
Context.API.GetTranslation("plugin_pluginsmanager_update_failed_subtitle"), icoPath, false),
|
||||
TaskContinuationOptions.OnlyOnFaulted);
|
||||
if (!silent)
|
||||
_downloadManifestTask.ContinueWith(_ =>
|
||||
Context.API.ShowMsg(Context.API.GetTranslation("plugin_pluginsmanager_update_failed_title"),
|
||||
Context.API.GetTranslation("plugin_pluginsmanager_update_failed_subtitle"), icoPath, false),
|
||||
TaskContinuationOptions.OnlyOnFaulted);
|
||||
return _downloadManifestTask;
|
||||
}
|
||||
}
|
||||
|
|
@ -113,8 +114,8 @@ namespace Flow.Launcher.Plugin.PluginsManager
|
|||
.Any(x => x.Metadata.ID == plugin.ID && x.Metadata.Version.CompareTo(plugin.Version) < 0))
|
||||
{
|
||||
if (MessageBox.Show(Context.API.GetTranslation("plugin_pluginsmanager_update_exists"),
|
||||
Context.API.GetTranslation("plugin_pluginsmanager_update_title"),
|
||||
MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
||||
Context.API.GetTranslation("plugin_pluginsmanager_update_title"),
|
||||
MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
||||
Context
|
||||
.API
|
||||
.ChangeQuery(
|
||||
|
|
@ -138,13 +139,13 @@ namespace Flow.Launcher.Plugin.PluginsManager
|
|||
Environment.NewLine, Environment.NewLine);
|
||||
|
||||
if (MessageBox.Show(message, Context.API.GetTranslation("plugin_pluginsmanager_install_title"),
|
||||
MessageBoxButton.YesNo) == MessageBoxResult.No)
|
||||
MessageBoxButton.YesNo) == MessageBoxResult.No)
|
||||
return;
|
||||
|
||||
// at minimum should provide a name, but handle plugin that is not downloaded from plugins manifest and is a url download
|
||||
var downloadFilename = string.IsNullOrEmpty(plugin.Version)
|
||||
? $"{plugin.Name}-{Guid.NewGuid()}.zip"
|
||||
: $"{plugin.Name}-{plugin.Version}.zip";
|
||||
? $"{plugin.Name}-{Guid.NewGuid()}.zip"
|
||||
: $"{plugin.Name}-{plugin.Version}.zip";
|
||||
|
||||
var filePath = Path.Combine(DataLocation.PluginsDirectory, downloadFilename);
|
||||
|
||||
|
|
@ -161,7 +162,7 @@ namespace Flow.Launcher.Plugin.PluginsManager
|
|||
{
|
||||
if (e is HttpRequestException)
|
||||
MessageBox.Show(Context.API.GetTranslation("plugin_pluginsmanager_download_error"),
|
||||
Context.API.GetTranslation("plugin_pluginsmanager_downloading_plugin"));
|
||||
Context.API.GetTranslation("plugin_pluginsmanager_downloading_plugin"));
|
||||
|
||||
Context.API.ShowMsgError(Context.API.GetTranslation("plugin_pluginsmanager_install_error_title"),
|
||||
string.Format(Context.API.GetTranslation("plugin_pluginsmanager_install_error_subtitle"),
|
||||
|
|
@ -173,7 +174,7 @@ namespace Flow.Launcher.Plugin.PluginsManager
|
|||
}
|
||||
|
||||
Context.API.ShowMsg(Context.API.GetTranslation("plugin_pluginsmanager_install_title"),
|
||||
Context.API.GetTranslation("plugin_pluginsmanager_install_success_restart"));
|
||||
Context.API.GetTranslation("plugin_pluginsmanager_install_success_restart"));
|
||||
|
||||
Context.API.RestartApp();
|
||||
}
|
||||
|
|
@ -241,8 +242,8 @@ namespace Flow.Launcher.Plugin.PluginsManager
|
|||
Environment.NewLine, Environment.NewLine);
|
||||
|
||||
if (MessageBox.Show(message,
|
||||
Context.API.GetTranslation("plugin_pluginsmanager_update_title"),
|
||||
MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
||||
Context.API.GetTranslation("plugin_pluginsmanager_update_title"),
|
||||
MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
||||
{
|
||||
Uninstall(x.PluginExistingMetadata, false);
|
||||
|
||||
|
|
@ -277,11 +278,10 @@ namespace Flow.Launcher.Plugin.PluginsManager
|
|||
|
||||
return false;
|
||||
},
|
||||
ContextData =
|
||||
ContextData =
|
||||
new UserPlugin
|
||||
{
|
||||
Website = x.PluginNewUserPlugin.Website,
|
||||
UrlSourceCode = x.PluginNewUserPlugin.UrlSourceCode
|
||||
Website = x.PluginNewUserPlugin.Website, UrlSourceCode = x.PluginNewUserPlugin.UrlSourceCode
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -340,21 +340,24 @@ namespace Flow.Launcher.Plugin.PluginsManager
|
|||
if (Settings.WarnFromUnknownSource)
|
||||
{
|
||||
if (!InstallSourceKnown(plugin.UrlDownload)
|
||||
&& MessageBox.Show(string.Format(Context.API.GetTranslation("plugin_pluginsmanager_install_unknown_source_warning"),
|
||||
Environment.NewLine),
|
||||
Context.API.GetTranslation("plugin_pluginsmanager_install_unknown_source_warning_title"),
|
||||
MessageBoxButton.YesNo) == MessageBoxResult.No)
|
||||
&& MessageBox.Show(string.Format(Context.API.GetTranslation("plugin_pluginsmanager_install_unknown_source_warning"),
|
||||
Environment.NewLine),
|
||||
Context.API.GetTranslation("plugin_pluginsmanager_install_unknown_source_warning_title"),
|
||||
MessageBoxButton.YesNo) == MessageBoxResult.No)
|
||||
return false;
|
||||
}
|
||||
|
||||
Application.Current.MainWindow.Hide();
|
||||
_ = InstallOrUpdate(plugin);
|
||||
|
||||
|
||||
return ShouldHideWindow;
|
||||
}
|
||||
};
|
||||
|
||||
return new List<Result> { result };
|
||||
return new List<Result>
|
||||
{
|
||||
result
|
||||
};
|
||||
}
|
||||
|
||||
private bool InstallSourceKnown(string url)
|
||||
|
|
@ -377,7 +380,7 @@ namespace Flow.Launcher.Plugin.PluginsManager
|
|||
|
||||
var searchNameWithoutKeyword = searchName.Replace(Settings.HotKeyInstall, string.Empty, StringComparison.OrdinalIgnoreCase).Trim();
|
||||
|
||||
if (Uri.IsWellFormedUriString(searchNameWithoutKeyword, UriKind.Absolute)
|
||||
if (Uri.IsWellFormedUriString(searchNameWithoutKeyword, UriKind.Absolute)
|
||||
&& searchNameWithoutKeyword.Split('.').Last() == zip)
|
||||
return InstallFromWeb(searchNameWithoutKeyword);
|
||||
|
||||
|
|
@ -438,21 +441,21 @@ namespace Flow.Launcher.Plugin.PluginsManager
|
|||
if (string.IsNullOrEmpty(metadataJsonFilePath) || string.IsNullOrEmpty(pluginFolderPath))
|
||||
{
|
||||
MessageBox.Show(Context.API.GetTranslation("plugin_pluginsmanager_install_errormetadatafile"),
|
||||
Context.API.GetTranslation("plugin_pluginsmanager_install_error_title"));
|
||||
|
||||
throw new FileNotFoundException (
|
||||
Context.API.GetTranslation("plugin_pluginsmanager_install_error_title"));
|
||||
|
||||
throw new FileNotFoundException(
|
||||
string.Format("Unable to find plugin.json from the extracted zip file, or this path {0} does not exist", pluginFolderPath));
|
||||
}
|
||||
|
||||
if (SameOrLesserPluginVersionExists(metadataJsonFilePath))
|
||||
{
|
||||
MessageBox.Show(string.Format(Context.API.GetTranslation("plugin_pluginsmanager_install_error_duplicate"), plugin.Name),
|
||||
Context.API.GetTranslation("plugin_pluginsmanager_install_error_title"));
|
||||
Context.API.GetTranslation("plugin_pluginsmanager_install_error_title"));
|
||||
|
||||
throw new InvalidOperationException(
|
||||
string.Format("A plugin with the same ID and version already exists, " +
|
||||
"or the version is greater than this downloaded plugin {0}",
|
||||
plugin.Name));
|
||||
"or the version is greater than this downloaded plugin {0}",
|
||||
plugin.Name));
|
||||
}
|
||||
|
||||
var directory = string.IsNullOrEmpty(plugin.Version) ? $"{plugin.Name}-{Guid.NewGuid()}" : $"{plugin.Name}-{plugin.Version}";
|
||||
|
|
@ -491,8 +494,8 @@ namespace Flow.Launcher.Plugin.PluginsManager
|
|||
Environment.NewLine, Environment.NewLine);
|
||||
|
||||
if (MessageBox.Show(message,
|
||||
Context.API.GetTranslation("plugin_pluginsmanager_uninstall_title"),
|
||||
MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
||||
Context.API.GetTranslation("plugin_pluginsmanager_uninstall_title"),
|
||||
MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
||||
{
|
||||
Application.Current.MainWindow.Hide();
|
||||
Uninstall(x.Metadata);
|
||||
|
|
@ -554,8 +557,8 @@ namespace Flow.Launcher.Plugin.PluginsManager
|
|||
{
|
||||
var newMetadata = JsonSerializer.Deserialize<PluginMetadata>(File.ReadAllText(metadataPath));
|
||||
return Context.API.GetAllPlugins()
|
||||
.Any(x => x.Metadata.ID == newMetadata.ID
|
||||
&& newMetadata.Version.CompareTo(x.Metadata.Version) <= 0);
|
||||
.Any(x => x.Metadata.ID == newMetadata.ID
|
||||
&& newMetadata.Version.CompareTo(x.Metadata.Version) <= 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue