Skip to content

Commit

Permalink
Make sure that duplicate Addon install requests don't lead to duplica…
Browse files Browse the repository at this point in the history
…tes in the installed_addon list
  • Loading branch information
Grumbel committed Aug 25, 2014
1 parent f72cd83 commit ebfce57
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/addon/addon_manager.cpp
Expand Up @@ -181,7 +181,27 @@ AddonManager::check_online()
void
AddonManager::install_addon(const AddonId& addon_id)
{
log_debug << "installing addon " << addon_id << std::endl;
{ // remove addon if it already exists
auto it = std::find_if(m_installed_addons.begin(), m_installed_addons.end(),
[&addon_id](const std::unique_ptr<Addon>& addon)
{
return addon->get_id() == addon_id;
});
if (it != m_installed_addons.end())
{
log_debug << "reinstalling addon " << addon_id << std::endl;
if ((*it)->is_enabled())
{
disable_addon((*it)->get_id());
}
m_installed_addons.erase(it);
}
else
{
log_debug << "installing addon " << addon_id << std::endl;
}
}

Addon& repository_addon = get_repository_addon(addon_id);

std::string install_filename = FileSystem::join(m_addon_directory, repository_addon.get_filename());
Expand Down

0 comments on commit ebfce57

Please sign in to comment.