Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #4079 from t-nelson/speed_up_repo_update_abort

Pivos: Speed up aborting addon repo update job.
  • Loading branch information...
commit 002c64a4a13b81cd10a7a10725646f3fdea2ad2c 2 parents e91c182 + b0c8800
@jmarshallnz jmarshallnz authored
Showing with 22 additions and 3 deletions.
  1. +21 −2 xbmc/addons/Repository.cpp
  2. +1 −1  xbmc/addons/Repository.h
View
23 xbmc/addons/Repository.cpp
@@ -107,6 +107,9 @@ CRepository::~CRepository()
string CRepository::Checksum() const
{
+ /* This code is duplicated in CRepositoryUpdateJob::GrabAddons().
+ * If you make changes here, they may be applicable there, too.
+ */
string result;
for (DirList::const_iterator it = m_dirs.begin(); it != m_dirs.end(); ++it)
{
@@ -232,6 +235,8 @@ bool CRepositoryUpdateJob::DoWork()
map<string, AddonPtr> addons;
for (VECADDONS::const_iterator i = m_repos.begin(); i != m_repos.end(); ++i)
{
+ if (ShouldCancel(0, 0))
+ return false;
RepositoryPtr repo = boost::dynamic_pointer_cast<CRepository>(*i);
VECADDONS newAddons = GrabAddons(repo);
MergeAddons(addons, newAddons);
@@ -322,16 +327,30 @@ bool CRepositoryUpdateJob::DoWork()
VECADDONS CRepositoryUpdateJob::GrabAddons(RepositoryPtr& repo)
{
CAddonDatabase database;
+ VECADDONS addons;
database.Open();
string checksum;
database.GetRepoChecksum(repo->ID(),checksum);
- string reposum = repo->Checksum();
- VECADDONS addons;
+ string reposum;
+
+ /* This for loop is duplicated in CRepository::Checksum().
+ * If you make changes here, they may be applicable there, too.
+ */
+ for (CRepository::DirList::const_iterator it = repo->m_dirs.begin(); it != repo->m_dirs.end(); ++it)
+ {
+ if (ShouldCancel(0, 0))
+ return addons;
+ if (!it->checksum.empty())
+ reposum += CRepository::FetchChecksum(it->checksum);
+ }
+
if (checksum != reposum || checksum.empty())
{
map<string, AddonPtr> uniqueAddons;
for (CRepository::DirList::const_iterator it = repo->m_dirs.begin(); it != repo->m_dirs.end(); ++it)
{
+ if (ShouldCancel(0, 0))
+ return addons;
VECADDONS addons2 = CRepository::Parse(*it);
MergeAddons(uniqueAddons, addons2);
}
View
2  xbmc/addons/Repository.h
@@ -58,8 +58,8 @@ namespace ADDON
DirList m_dirs;
static VECADDONS Parse(const DirInfo& dir);
- private:
static std::string FetchChecksum(const std::string& url);
+ private:
CRepository(const CRepository &rhs);
};
Please sign in to comment.
Something went wrong with that request. Please try again.