Skip to content

Commit 350423b

Browse files
authored
Merge pull request #3054 from Flow-Launcher/fix-install-source-author
fix out of index error when install source is not standard github link
2 parents 009f71a + a9da2af commit 350423b

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

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

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,11 @@ internal async ValueTask<List<Result>> RequestUpdateAsync(string search, Cancell
203203
pluginFromLocalPath = Utilities.GetPluginInfoFromZip(search);
204204
pluginFromLocalPath.LocalInstallPath = search;
205205
updateFromLocalPath = true;
206-
}
206+
}
207207

208208
var updateSource = !updateFromLocalPath
209-
? PluginsManifest.UserPlugins
210-
: new List<UserPlugin> { pluginFromLocalPath };
209+
? PluginsManifest.UserPlugins
210+
: new List<UserPlugin> { pluginFromLocalPath };
211211

212212
var resultsForUpdate = (
213213
from existingPlugin in Context.API.GetAllPlugins()
@@ -291,7 +291,7 @@ await Http.DownloadAsync(x.PluginNewUserPlugin.UrlDownload, downloadToFilePath)
291291
{
292292
downloadToFilePath = x.PluginNewUserPlugin.LocalInstallPath;
293293
}
294-
294+
295295

296296
PluginManager.UpdatePlugin(x.PluginExistingMetadata, x.PluginNewUserPlugin,
297297
downloadToFilePath);
@@ -327,7 +327,6 @@ await Http.DownloadAsync(x.PluginNewUserPlugin.UrlDownload, downloadToFilePath)
327327
}, TaskContinuationOptions.OnlyOnFaulted);
328328

329329
return true;
330-
331330
},
332331
ContextData =
333332
new UserPlugin
@@ -513,7 +512,8 @@ internal List<Result> InstallFromLocalPath(string localPath)
513512
{
514513
if (!InstallSourceKnown(plugin.Website)
515514
&& MessageBox.Show(string.Format(
516-
Context.API.GetTranslation("plugin_pluginsmanager_install_unknown_source_warning"),
515+
Context.API.GetTranslation(
516+
"plugin_pluginsmanager_install_unknown_source_warning"),
517517
Environment.NewLine),
518518
Context.API.GetTranslation(
519519
"plugin_pluginsmanager_install_unknown_source_warning_title"),
@@ -532,7 +532,12 @@ internal List<Result> InstallFromLocalPath(string localPath)
532532

533533
private bool InstallSourceKnown(string url)
534534
{
535-
var author = url.Split('/')[3];
535+
var pieces = url.Split('/');
536+
537+
if (pieces.Length < 4)
538+
return false;
539+
540+
var author = pieces[3];
536541
var acceptedSource = "https://github.com";
537542
var constructedUrlPart = string.Format("{0}/{1}/", acceptedSource, author);
538543

@@ -589,7 +594,7 @@ private void Install(UserPlugin plugin, string downloadedFilePath)
589594
try
590595
{
591596
PluginManager.InstallPlugin(plugin, downloadedFilePath);
592-
597+
593598
if (!plugin.IsFromLocalInstallPath)
594599
File.Delete(downloadedFilePath);
595600
}

0 commit comments

Comments
 (0)