Skip to content

Commit

Permalink
Merge pull request #3054 from Flow-Launcher/fix-install-source-author
Browse files Browse the repository at this point in the history
fix out of index error when install source is not standard github link
  • Loading branch information
jjw24 authored Oct 31, 2024
2 parents 009f71a + a9da2af commit 350423b
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,11 @@ internal async ValueTask<List<Result>> RequestUpdateAsync(string search, Cancell
pluginFromLocalPath = Utilities.GetPluginInfoFromZip(search);
pluginFromLocalPath.LocalInstallPath = search;
updateFromLocalPath = true;
}
}

var updateSource = !updateFromLocalPath
? PluginsManifest.UserPlugins
: new List<UserPlugin> { pluginFromLocalPath };
? PluginsManifest.UserPlugins
: new List<UserPlugin> { pluginFromLocalPath };

var resultsForUpdate = (
from existingPlugin in Context.API.GetAllPlugins()
Expand Down Expand Up @@ -291,7 +291,7 @@ await Http.DownloadAsync(x.PluginNewUserPlugin.UrlDownload, downloadToFilePath)
{
downloadToFilePath = x.PluginNewUserPlugin.LocalInstallPath;
}


PluginManager.UpdatePlugin(x.PluginExistingMetadata, x.PluginNewUserPlugin,
downloadToFilePath);
Expand Down Expand Up @@ -327,7 +327,6 @@ await Http.DownloadAsync(x.PluginNewUserPlugin.UrlDownload, downloadToFilePath)
}, TaskContinuationOptions.OnlyOnFaulted);

return true;

},
ContextData =
new UserPlugin
Expand Down Expand Up @@ -513,7 +512,8 @@ internal List<Result> InstallFromLocalPath(string localPath)
{
if (!InstallSourceKnown(plugin.Website)
&& MessageBox.Show(string.Format(
Context.API.GetTranslation("plugin_pluginsmanager_install_unknown_source_warning"),
Context.API.GetTranslation(
"plugin_pluginsmanager_install_unknown_source_warning"),
Environment.NewLine),
Context.API.GetTranslation(
"plugin_pluginsmanager_install_unknown_source_warning_title"),
Expand All @@ -532,7 +532,12 @@ internal List<Result> InstallFromLocalPath(string localPath)

private bool InstallSourceKnown(string url)
{
var author = url.Split('/')[3];
var pieces = url.Split('/');

if (pieces.Length < 4)
return false;

var author = pieces[3];
var acceptedSource = "https://github.com";
var constructedUrlPart = string.Format("{0}/{1}/", acceptedSource, author);

Expand Down Expand Up @@ -589,7 +594,7 @@ private void Install(UserPlugin plugin, string downloadedFilePath)
try
{
PluginManager.InstallPlugin(plugin, downloadedFilePath);

if (!plugin.IsFromLocalInstallPath)
File.Delete(downloadedFilePath);
}
Expand Down

0 comments on commit 350423b

Please sign in to comment.