aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Sommerfeld <kai.sommerfeld@gmx.com>2022-10-15 00:48:14 +0200
committerKai Sommerfeld <kai.sommerfeld@gmx.com>2022-10-17 23:20:27 +0200
commit5edbefdb3a31dcb5ab6910cc6f715c12f9629d8a (patch)
tree205f5f6ab25c7ac0610db0729fa5faf5f81aa90b
parent9cb7a51a90712f47a4566e3c661b1fa76433b515 (diff)
[addons] Make CRepositoryUpdateJob internal for CRepositoryUpdater.
-rw-r--r--xbmc/addons/Repository.cpp70
-rw-r--r--xbmc/addons/Repository.h16
-rw-r--r--xbmc/addons/RepositoryUpdater.cpp83
3 files changed, 84 insertions, 85 deletions
diff --git a/xbmc/addons/Repository.cpp b/xbmc/addons/Repository.cpp
index 4361acfe3e..cb96389d6e 100644
--- a/xbmc/addons/Repository.cpp
+++ b/xbmc/addons/Repository.cpp
@@ -10,7 +10,6 @@
#include "FileItem.h"
#include "ServiceBroker.h"
-#include "TextureDatabase.h"
#include "URL.h"
#include "addons/AddonDatabase.h"
#include "addons/AddonInstaller.h"
@@ -327,72 +326,3 @@ CRepository::DirInfo CRepository::ParseDirConfiguration(const CAddonExtensions&
return dir;
}
-
-CRepositoryUpdateJob::CRepositoryUpdateJob(const RepositoryPtr& repo) : m_repo(repo) {}
-
-bool CRepositoryUpdateJob::DoWork()
-{
- CLog::Log(LOGDEBUG, "CRepositoryUpdateJob[{}] checking for updates.", m_repo->ID());
- CAddonDatabase database;
- database.Open();
-
- std::string oldChecksum;
- if (database.GetRepoChecksum(m_repo->ID(), oldChecksum) == -1)
- oldChecksum = "";
-
- const CAddonDatabase::RepoUpdateData updateData{database.GetRepoUpdateData(m_repo->ID())};
- if (updateData.lastCheckedVersion != m_repo->Version())
- oldChecksum = "";
-
- std::string newChecksum;
- std::vector<AddonInfoPtr> addons;
- int recheckAfter;
- auto status = m_repo->FetchIfChanged(oldChecksum, newChecksum, addons, recheckAfter);
-
- database.SetRepoUpdateData(
- m_repo->ID(), CAddonDatabase::RepoUpdateData(
- CDateTime::GetCurrentDateTime(), m_repo->Version(),
- CDateTime::GetCurrentDateTime() + CDateTimeSpan(0, 0, 0, recheckAfter)));
-
- MarkFinished();
-
- if (status == CRepository::STATUS_ERROR)
- return false;
-
- if (status == CRepository::STATUS_NOT_MODIFIED)
- {
- CLog::Log(LOGDEBUG, "CRepositoryUpdateJob[{}] checksum not changed.", m_repo->ID());
- return true;
- }
-
- //Invalidate art.
- {
- CTextureDatabase textureDB;
- textureDB.Open();
- textureDB.BeginMultipleExecute();
-
- for (const auto& addon : addons)
- {
- AddonPtr oldAddon;
- if (CServiceBroker::GetAddonMgr().FindInstallableById(addon->ID(), oldAddon) && oldAddon &&
- addon->Version() > oldAddon->Version())
- {
- if (!oldAddon->Icon().empty() || !oldAddon->Art().empty() || !oldAddon->Screenshots().empty())
- CLog::Log(LOGDEBUG, "CRepository: invalidating cached art for '{}'", addon->ID());
-
- if (!oldAddon->Icon().empty())
- textureDB.InvalidateCachedTexture(oldAddon->Icon());
-
- for (const auto& path : oldAddon->Screenshots())
- textureDB.InvalidateCachedTexture(path);
-
- for (const auto& art : oldAddon->Art())
- textureDB.InvalidateCachedTexture(art.second);
- }
- }
- textureDB.CommitMultipleExecute();
- }
-
- database.UpdateRepositoryContent(m_repo->ID(), m_repo->Version(), newChecksum, addons);
- return true;
-}
diff --git a/xbmc/addons/Repository.h b/xbmc/addons/Repository.h
index be9fdb8b89..4f0306dc2b 100644
--- a/xbmc/addons/Repository.h
+++ b/xbmc/addons/Repository.h
@@ -11,7 +11,6 @@
#include "addons/Addon.h"
#include "addons/AddonVersion.h"
#include "utils/Digest.h"
-#include "utils/ProgressJob.h"
#include <memory>
#include <string>
@@ -72,19 +71,6 @@ private:
DirList m_dirs;
};
- typedef std::shared_ptr<CRepository> RepositoryPtr;
-
-
- class CRepositoryUpdateJob : public CProgressJob
- {
- public:
- explicit CRepositoryUpdateJob(const RepositoryPtr& repo);
- ~CRepositoryUpdateJob() override = default;
- bool DoWork() override;
- const RepositoryPtr& GetAddon() const { return m_repo; }
-
- private:
- const RepositoryPtr m_repo;
- };
+typedef std::shared_ptr<CRepository> RepositoryPtr;
}
diff --git a/xbmc/addons/RepositoryUpdater.cpp b/xbmc/addons/RepositoryUpdater.cpp
index d3acfe6ed4..dae983c153 100644
--- a/xbmc/addons/RepositoryUpdater.cpp
+++ b/xbmc/addons/RepositoryUpdater.cpp
@@ -9,12 +9,14 @@
#include "RepositoryUpdater.h"
#include "ServiceBroker.h"
+#include "TextureDatabase.h"
#include "addons/AddonDatabase.h"
#include "addons/AddonEvents.h"
#include "addons/AddonInstaller.h"
#include "addons/AddonManager.h"
#include "addons/AddonSystemSettings.h"
#include "addons/Repository.h"
+#include "addons/addoninfo/AddonInfo.h"
#include "addons/addoninfo/AddonType.h"
#include "dialogs/GUIDialogExtendedProgressBar.h"
#include "dialogs/GUIDialogKaiToast.h"
@@ -27,6 +29,7 @@
#include "settings/SettingsComponent.h"
#include "settings/lib/Setting.h"
#include "utils/JobManager.h"
+#include "utils/ProgressJob.h"
#include "utils/log.h"
#include <algorithm>
@@ -39,6 +42,86 @@ using namespace std::chrono_literals;
namespace ADDON
{
+class CRepositoryUpdateJob : public CProgressJob
+{
+public:
+ explicit CRepositoryUpdateJob(const RepositoryPtr& repo) : m_repo(repo) {}
+ ~CRepositoryUpdateJob() override = default;
+ bool DoWork() override;
+ const RepositoryPtr& GetAddon() const { return m_repo; }
+
+private:
+ const RepositoryPtr m_repo;
+};
+
+bool CRepositoryUpdateJob::DoWork()
+{
+ CLog::Log(LOGDEBUG, "CRepositoryUpdateJob[{}] checking for updates.", m_repo->ID());
+ CAddonDatabase database;
+ database.Open();
+
+ std::string oldChecksum;
+ if (database.GetRepoChecksum(m_repo->ID(), oldChecksum) == -1)
+ oldChecksum = "";
+
+ const CAddonDatabase::RepoUpdateData updateData{database.GetRepoUpdateData(m_repo->ID())};
+ if (updateData.lastCheckedVersion != m_repo->Version())
+ oldChecksum = "";
+
+ std::string newChecksum;
+ std::vector<AddonInfoPtr> addons;
+ int recheckAfter;
+ auto status = m_repo->FetchIfChanged(oldChecksum, newChecksum, addons, recheckAfter);
+
+ database.SetRepoUpdateData(
+ m_repo->ID(), CAddonDatabase::RepoUpdateData(
+ CDateTime::GetCurrentDateTime(), m_repo->Version(),
+ CDateTime::GetCurrentDateTime() + CDateTimeSpan(0, 0, 0, recheckAfter)));
+
+ MarkFinished();
+
+ if (status == CRepository::STATUS_ERROR)
+ return false;
+
+ if (status == CRepository::STATUS_NOT_MODIFIED)
+ {
+ CLog::Log(LOGDEBUG, "CRepositoryUpdateJob[{}] checksum not changed.", m_repo->ID());
+ return true;
+ }
+
+ //Invalidate art.
+ {
+ CTextureDatabase textureDB;
+ textureDB.Open();
+ textureDB.BeginMultipleExecute();
+
+ for (const auto& addon : addons)
+ {
+ AddonPtr oldAddon;
+ if (CServiceBroker::GetAddonMgr().FindInstallableById(addon->ID(), oldAddon) && oldAddon &&
+ addon->Version() > oldAddon->Version())
+ {
+ if (!oldAddon->Icon().empty() || !oldAddon->Art().empty() ||
+ !oldAddon->Screenshots().empty())
+ CLog::Log(LOGDEBUG, "CRepository: invalidating cached art for '{}'", addon->ID());
+
+ if (!oldAddon->Icon().empty())
+ textureDB.InvalidateCachedTexture(oldAddon->Icon());
+
+ for (const auto& path : oldAddon->Screenshots())
+ textureDB.InvalidateCachedTexture(path);
+
+ for (const auto& art : oldAddon->Art())
+ textureDB.InvalidateCachedTexture(art.second);
+ }
+ }
+ textureDB.CommitMultipleExecute();
+ }
+
+ database.UpdateRepositoryContent(m_repo->ID(), m_repo->Version(), newChecksum, addons);
+ return true;
+}
+
CRepositoryUpdater::CRepositoryUpdater(CAddonMgr& addonMgr) :
m_timer(this),
m_doneEvent(true),