projects
/
supertux.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ebfce57
)
Keep proper track of MD5 checksums of addons
author
Ingo Ruhnke
<grumbel@gmail.com>
Sat, 23 Aug 2014 19:07:25 +0000
(21:07 +0200)
committer
Ingo Ruhnke
<grumbel@gmail.com>
Mon, 25 Aug 2014 07:52:11 +0000
(09:52 +0200)
src/addon/addon.cpp
patch
|
blob
|
history
src/addon/addon.hpp
patch
|
blob
|
history
src/addon/addon_manager.cpp
patch
|
blob
|
history
src/addon/addon_manager.hpp
patch
|
blob
|
history
src/supertux/menu/addon_menu.cpp
patch
|
blob
|
history
diff --git
a/src/addon/addon.cpp
b/src/addon/addon.cpp
index
b453697
..
4683b03
100644
(file)
--- a/
src/addon/addon.cpp
+++ b/
src/addon/addon.cpp
@@
-159,9
+159,10
@@
Addon::is_enabled() const
}
void
}
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_install_filename = absolute_filename;
+ m_md5 = md5;
}
void
}
void
diff --git
a/src/addon/addon.hpp
b/src/addon/addon.hpp
index
81cf349
..
34e49aa
100644
(file)
--- a/
src/addon/addon.hpp
+++ b/
src/addon/addon.hpp
@@
-70,7
+70,7
@@
public:
bool is_installed() const;
bool is_enabled() const;
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:
void set_enabled(bool v);
private:
diff --git
a/src/addon/addon_manager.cpp
b/src/addon/addon_manager.cpp
index
5153592
..
acd983f
100644
(file)
--- a/
src/addon/addon_manager.cpp
+++ b/
src/addon/addon_manager.cpp
@@
-227,7
+227,7
@@
AddonManager::install_addon(const AddonId& addon_id)
}
else
{
}
else
{
- add_installed_archive(install_filename);
+ add_installed_archive(install_filename
, md5.hex_digest()
);
}
}
}
}
}
}
@@
-358,7
+358,7
@@
AddonManager::scan_for_info(const std::string& archive_os_path) const
}
void
}
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)
{
const char* realdir = PHYSFS_getRealDir(archive.c_str());
if (!realdir)
@@
-383,7
+383,7
@@
AddonManager::add_installed_archive(const std::string& archive)
try
{
std::unique_ptr<Addon> addon = Addon::parse(nfo_filename);
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)
m_installed_addons.push_back(std::move(addon));
}
catch (const std::runtime_error& e)
@@
-403,7
+403,8
@@
AddonManager::add_installed_addons()
for(auto archive : archives)
{
for(auto archive : archives)
{
- add_installed_archive(archive);
+ MD5 md5 = md5_from_file(archive);
+ add_installed_archive(archive, md5.hex_digest());
}
}
}
}
diff --git
a/src/addon/addon_manager.hpp
b/src/addon/addon_manager.hpp
index
cd11671
..
68e1953
100644
(file)
--- a/
src/addon/addon_manager.hpp
+++ b/
src/addon/addon_manager.hpp
@@
-73,7
+73,7
@@
private:
/** add \a archive, given as physfs path, to the list of installed
archives */
/** 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 */
/** search for an .nfo file in the top level directory that
originates from \a archive, \a archive is a OS path */
diff --git
a/src/supertux/menu/addon_menu.cpp
b/src/supertux/menu/addon_menu.cpp
index
d2e6c5b
..
704d1d2
100644
(file)
--- a/
src/supertux/menu/addon_menu.cpp
+++ b/
src/supertux/menu/addon_menu.cpp
@@
-109,7
+109,7
@@
AddonMenu::rebuild_menu()
add_label(_("Add-ons"));
add_hl();
add_label(_("Add-ons"));
add_hl();
-
+
if (!m_installed_addons.empty())
{
int idx = 0;
if (!m_installed_addons.empty())
{
int idx = 0;
@@
-117,7
+117,7
@@
AddonMenu::rebuild_menu()
{
const Addon& addon = m_addon_manager.get_installed_addon(addon_id);
std::string text = generate_menu_item_text(addon);
{
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;
}
idx += 1;
}
@@
-145,12
+145,16
@@
AddonMenu::rebuild_menu()
if (installed_addon.get_md5() == addon.get_md5() ||
installed_addon.get_version() > addon.get_version())
{
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
{
}
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);
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;
}
}
idx += 1;
}
}
@@
-193,7
+197,7
@@
AddonMenu::menu_action(MenuItem* item)
const Addon& addon = m_addon_manager.get_installed_addon(m_installed_addons[idx]);
if(addon.is_enabled())
{
const Addon& addon = m_addon_manager.get_installed_addon(m_installed_addons[idx]);
if(addon.is_enabled())
{
- m_addon_manager.
en
able_addon(addon.get_id());
+ m_addon_manager.
dis
able_addon(addon.get_id());
set_toggled(item->id, addon.is_enabled());
}
else
set_toggled(item->id, addon.is_enabled());
}
else