Skip to content
This repository
Browse code

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 2 changed files with 22 additions and 3 deletions. Show diff stats Hide diff stats

  1. +21 2 xbmc/addons/Repository.cpp
  2. +1 1  xbmc/addons/Repository.h
23 xbmc/addons/Repository.cpp
@@ -107,6 +107,9 @@ CRepository::~CRepository()
107 107
108 108 string CRepository::Checksum() const
109 109 {
  110 + /* This code is duplicated in CRepositoryUpdateJob::GrabAddons().
  111 + * If you make changes here, they may be applicable there, too.
  112 + */
110 113 string result;
111 114 for (DirList::const_iterator it = m_dirs.begin(); it != m_dirs.end(); ++it)
112 115 {
@@ -232,6 +235,8 @@ bool CRepositoryUpdateJob::DoWork()
232 235 map<string, AddonPtr> addons;
233 236 for (VECADDONS::const_iterator i = m_repos.begin(); i != m_repos.end(); ++i)
234 237 {
  238 + if (ShouldCancel(0, 0))
  239 + return false;
235 240 RepositoryPtr repo = boost::dynamic_pointer_cast<CRepository>(*i);
236 241 VECADDONS newAddons = GrabAddons(repo);
237 242 MergeAddons(addons, newAddons);
@@ -322,16 +327,30 @@ bool CRepositoryUpdateJob::DoWork()
322 327 VECADDONS CRepositoryUpdateJob::GrabAddons(RepositoryPtr& repo)
323 328 {
324 329 CAddonDatabase database;
  330 + VECADDONS addons;
325 331 database.Open();
326 332 string checksum;
327 333 database.GetRepoChecksum(repo->ID(),checksum);
328   - string reposum = repo->Checksum();
329   - VECADDONS addons;
  334 + string reposum;
  335 +
  336 + /* This for loop is duplicated in CRepository::Checksum().
  337 + * If you make changes here, they may be applicable there, too.
  338 + */
  339 + for (CRepository::DirList::const_iterator it = repo->m_dirs.begin(); it != repo->m_dirs.end(); ++it)
  340 + {
  341 + if (ShouldCancel(0, 0))
  342 + return addons;
  343 + if (!it->checksum.empty())
  344 + reposum += CRepository::FetchChecksum(it->checksum);
  345 + }
  346 +
330 347 if (checksum != reposum || checksum.empty())
331 348 {
332 349 map<string, AddonPtr> uniqueAddons;
333 350 for (CRepository::DirList::const_iterator it = repo->m_dirs.begin(); it != repo->m_dirs.end(); ++it)
334 351 {
  352 + if (ShouldCancel(0, 0))
  353 + return addons;
335 354 VECADDONS addons2 = CRepository::Parse(*it);
336 355 MergeAddons(uniqueAddons, addons2);
337 356 }
2  xbmc/addons/Repository.h
@@ -58,8 +58,8 @@ namespace ADDON
58 58 DirList m_dirs;
59 59
60 60 static VECADDONS Parse(const DirInfo& dir);
61   - private:
62 61 static std::string FetchChecksum(const std::string& url);
  62 + private:
63 63 CRepository(const CRepository &rhs);
64 64 };
65 65

0 comments on commit 002c64a

Please sign in to comment.
Something went wrong with that request. Please try again.