}
void
-Addon::set_install_filename(const std::string& absolute_filename)
+Addon::set_install_filename(const std::string& absolute_filename, const std::string& md5)
{
m_install_filename = absolute_filename;
+ m_md5 = md5;
}
void
bool is_installed() const;
bool is_enabled() const;
- void set_install_filename(const std::string& absolute_filename);
+ void set_install_filename(const std::string& absolute_filename, const std::string& md5);
void set_enabled(bool v);
private:
}
else
{
- add_installed_archive(install_filename);
+ add_installed_archive(install_filename, md5.hex_digest());
}
}
}
}
void
-AddonManager::add_installed_archive(const std::string& archive)
+AddonManager::add_installed_archive(const std::string& archive, const std::string& md5)
{
const char* realdir = PHYSFS_getRealDir(archive.c_str());
if (!realdir)
try
{
std::unique_ptr<Addon> addon = Addon::parse(nfo_filename);
- addon->set_install_filename(os_path);
+ addon->set_install_filename(os_path, md5);
m_installed_addons.push_back(std::move(addon));
}
catch (const std::runtime_error& e)
for(auto archive : archives)
{
- add_installed_archive(archive);
+ MD5 md5 = md5_from_file(archive);
+ add_installed_archive(archive, md5.hex_digest());
}
}
/** add \a archive, given as physfs path, to the list of installed
archives */
- void add_installed_archive(const std::string& archive);
+ void add_installed_archive(const std::string& archive, const std::string& md5);
/** search for an .nfo file in the top level directory that
originates from \a archive, \a archive is a OS path */
add_label(_("Add-ons"));
add_hl();
-
+
if (!m_installed_addons.empty())
{
int idx = 0;
{
const Addon& addon = m_addon_manager.get_installed_addon(addon_id);
std::string text = generate_menu_item_text(addon);
- add_toggle(MAKE_INSTALLED_MENU_ID(idx), text, addon.is_enabled());
+ add_toggle(MAKE_INSTALLED_MENU_ID(idx), text, addon.is_enabled());
idx += 1;
}
if (installed_addon.get_md5() == addon.get_md5() ||
installed_addon.get_version() > addon.get_version())
{
- // addon alredy present, ignore it
+ log_debug << "ignoring already installed addon " << installed_addon.get_id() << std::endl;
}
else
{
+ log_debug << installed_addon.get_id() << " is installed, but updated: '"
+ << installed_addon.get_md5() << "' vs '" << addon.get_md5() << "' '"
+ << installed_addon.get_version() << "' vs '" << addon.get_version() << "'"
+ << std::endl;
std::string text = generate_menu_item_text(addon);
- add_entry(MAKE_REPOSITORY_MENU_ID(idx), "Install " + text + "*NEW*");
+ add_entry(MAKE_REPOSITORY_MENU_ID(idx), "Install " + text + " *NEW*");
idx += 1;
}
}
const Addon& addon = m_addon_manager.get_installed_addon(m_installed_addons[idx]);
if(addon.is_enabled())
{
- m_addon_manager.enable_addon(addon.get_id());
+ m_addon_manager.disable_addon(addon.get_id());
set_toggled(item->id, addon.is_enabled());
}
else