Always overwrite file when updating plugins, add additional logging to plugin management
This commit is contained in:
parent
41389f4746
commit
b2c6028cb8
2 changed files with 18 additions and 3 deletions
|
|
@ -44,6 +44,7 @@ void PluginManager::ScanAndLoadPlugins()
|
|||
|
||||
for(int i = 0; i < QDir(plugins_dir).entryList(QDir::Files).size(); i++)
|
||||
{
|
||||
LOG_TRACE("[PluginManager] Found plugin file %s", QDir(plugins_dir).entryList(QDir::Files)[i].toStdString().c_str());
|
||||
FileList.push_back(QDir(plugins_dir).entryList(QDir::Files)[i].toStdString());
|
||||
}
|
||||
|
||||
|
|
@ -97,6 +98,8 @@ void PluginManager::AddPlugin(std::string path)
|
|||
{
|
||||
if(plugin->GetPluginAPIVersion() == OPENRGB_PLUGIN_API_VERSION)
|
||||
{
|
||||
LOG_TRACE("[PluginManager] Plugin %s has a compatible API version", path.c_str());
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Get the plugin information |
|
||||
\*-----------------------------------------------------*/
|
||||
|
|
@ -184,6 +187,11 @@ void PluginManager::AddPlugin(std::string path)
|
|||
LoadPlugin(path);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
loader->unload();
|
||||
LOG_WARNING("[PluginManager] Plugin %s has an incompatible API version", path.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -193,6 +201,8 @@ void PluginManager::RemovePlugin(std::string path)
|
|||
{
|
||||
unsigned int plugin_idx;
|
||||
|
||||
LOG_TRACE("[PluginManager] Attempting to remove plugin %s", path.c_str());
|
||||
|
||||
/*---------------------------------------------------------------------*\
|
||||
| Search active plugins to see if this path already exists |
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
|
@ -209,6 +219,7 @@ void PluginManager::RemovePlugin(std::string path)
|
|||
\*---------------------------------------------------------------------*/
|
||||
if(plugin_idx == ActivePlugins.size())
|
||||
{
|
||||
LOG_TRACE("[PluginManager] Plugin %s not active", path.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -217,6 +228,7 @@ void PluginManager::RemovePlugin(std::string path)
|
|||
\*---------------------------------------------------------------------*/
|
||||
if(ActivePlugins[plugin_idx].loaded)
|
||||
{
|
||||
LOG_TRACE("[PluginManager] Plugin %s is active, unloading", path.c_str());
|
||||
UnloadPlugin(path);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -104,6 +104,8 @@ bool Ui::OpenRGBPluginsPage::InstallPlugin(std::string install_file)
|
|||
std::string to_file = to_path + filesystem::path(from_path).filename().string();
|
||||
bool match = false;
|
||||
|
||||
LOG_TRACE("[OpenRGBPluginsPage] Installing plugin %s", install_file.c_str());
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Check if a plugin with this path already exists |
|
||||
\*-----------------------------------------------------*/
|
||||
|
|
@ -139,7 +141,8 @@ bool Ui::OpenRGBPluginsPage::InstallPlugin(std::string install_file)
|
|||
{
|
||||
plugin_manager->RemovePlugin(to_file);
|
||||
|
||||
filesystem::copy(from_path, to_path, filesystem::copy_options::update_existing);
|
||||
LOG_TRACE("[OpenRGBPluginsPage] Copying from %s to %s", from_path.c_str(), to_path.c_str());
|
||||
filesystem::copy(from_path, to_path, filesystem::copy_options::overwrite_existing);
|
||||
|
||||
plugin_manager->AddPlugin(to_file);
|
||||
|
||||
|
|
@ -147,7 +150,7 @@ bool Ui::OpenRGBPluginsPage::InstallPlugin(std::string install_file)
|
|||
}
|
||||
catch(const std::exception& e)
|
||||
{
|
||||
LOG_ERROR("[PluginsManager] Failed to install plugin: %s", e.what());
|
||||
LOG_ERROR("[OpenRGBPluginsPage] Failed to install plugin: %s", e.what());
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue