diff --git a/src/Interface/Tabs/Plugin.as b/src/Interface/Tabs/Plugin.as index a512b66..88e1378 100644 --- a/src/Interface/Tabs/Plugin.as +++ b/src/Interface/Tabs/Plugin.as @@ -120,7 +120,7 @@ class PluginTab : Tab { m_updating = true; - PluginInstallAsync(m_plugin.m_siteID, m_plugin.m_id, m_plugin.m_version); + m_plugin.m_failedToInstall = !PluginInstallAsync(m_plugin.m_siteID, m_plugin.m_id, m_plugin.m_version); m_plugin.m_downloads++; m_plugin.CheckIfInstalled(); @@ -190,6 +190,16 @@ class PluginTab : Tab if (UI::GreenButton(Icons::Download + " Install")) { startnew(CoroutineFunc(InstallAsync)); } + + if (m_plugin.m_failedToInstall) { + const string helpLink = "https://openplanet.dev/docs/help"; + UI::SameLine(); + if (UI::RedButton(Icons::QuestionCircle + " Troubleshooting")) { + OpenBrowserURL(helpLink); + } + UI::SetItemTooltip(helpLink); + } + return; } diff --git a/src/Update.as b/src/Update.as index ccb59f7..b4e3cc3 100644 --- a/src/Update.as +++ b/src/Update.as @@ -18,7 +18,7 @@ void PluginUninstallAsync(ref@ metaPlugin) PluginCache::SyncRemove(pluginIdentifier); } -void PluginInstallAsync(int siteID, const string &in identifier, const Version &in version, bool load = true) +bool PluginInstallAsync(int siteID, const string &in identifier, const Version &in version, bool load = true) { warn("Installing plugin with site ID " + siteID + " and identifier \"" + identifier + "\""); @@ -35,6 +35,18 @@ void PluginInstallAsync(int siteID, const string &in identifier, const Version & yield(); } + if (IO::FileSize(savePath) == 0) { + const string msg = "Error installing plugin '" + identifier + "' "; + error(msg); + UI::ShowNotification(Icons::ShoppingCart + " Plugin Manager", msg, vec4(1.0f, 0.4f, 0.0f, 0.8f), 10000); + + if (IO::FileExists(savePath)) { + IO::Delete(savePath); + } + + return false; + } + if (load) { // Load the plugin auto plugin = Meta::LoadPlugin(savePath, Meta::PluginSource::UserFolder, Meta::PluginType::Zip); @@ -46,6 +58,8 @@ void PluginInstallAsync(int siteID, const string &in identifier, const Version & PluginCache::SyncUnloaded(identifier, siteID, version); } } + + return true; } void PluginUpdateAsync(ref@ update) diff --git a/src/Utils/PluginInfo.as b/src/Utils/PluginInfo.as index 692ef60..33e5063 100644 --- a/src/Utils/PluginInfo.as +++ b/src/Utils/PluginInfo.as @@ -32,6 +32,7 @@ class PluginInfo array m_changelogs; bool m_isInstalled; + bool m_failedToInstall = false; Net::HttpRequest@ m_changelogRequest; @@ -102,6 +103,7 @@ class PluginInfo // If the plugin is loaded, it's installed if (GetInstalledPlugin() !is null) { m_isInstalled = true; + m_failedToInstall = false; return; } @@ -109,6 +111,7 @@ class PluginInfo string path = IO::FromDataFolder("Plugins/" + m_id + ".op"); if (IO::FileExists(path)) { m_isInstalled = true; + m_failedToInstall = false; return; } }