Skip to content

Commit

Permalink
fixed: installating/updating several add-ons with the same dependencies
Browse files Browse the repository at this point in the history
if we had a job already registered, the Install() call in the dependency
install code would return false, thus halting the installation
we now wait around until the job finishes instead
  • Loading branch information
spiff committed Nov 14, 2011
1 parent ada86f4 commit b76bab8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
18 changes: 17 additions & 1 deletion xbmc/addons/AddonInstaller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,12 @@ void CAddonInstaller::UpdateRepos(bool force, bool wait)
}
}

bool CAddonInstaller::HasJob(const CStdString& ID) const
{
CSingleLock lock(m_critSection);
return m_downloadJobs.find(ID) != m_downloadJobs.end();
}

CAddonInstallJob::CAddonInstallJob(const AddonPtr &addon, const CStdString &hash, bool update, const CStdString &referer)
: m_addon(addon), m_hash(hash), m_update(update), m_referer(referer)
{
Expand Down Expand Up @@ -459,8 +465,18 @@ bool CAddonInstallJob::Install(const CStdString &installFrom)
AddonPtr dependency;
if (!CAddonMgr::Get().GetAddon(it->first,dependency) || dependency->Version() < it->second.first)
{
bool force=(dependency != NULL);
// dependency is already queued up for install - ::Install will fail
// instead we wait until the Job has finished. note that we
// recall install on purpose in case prior installation failed
if (CAddonInstaller::Get().HasJob(it->first))
{
while (CAddonInstaller::Get().HasJob(it->first))
Sleep(50);
force = false;
}
// don't have the addon or the addon isn't new enough - grab it (no new job for these)
if (!CAddonInstaller::Get().Install(it->first, dependency != NULL, referer, false))
if (!CAddonInstaller::Get().Install(it->first, force, referer, false))
{
DeleteAddon(addonFolder);
return false;
Expand Down
7 changes: 7 additions & 0 deletions xbmc/addons/AddonInstaller.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ class CAddonInstaller : public IJobCallback
\param force whether we should run an update regardless of the normal update cycle. Defaults to false.
\param wait whether we should busy wait for the updates to be performed. Defaults to false.
*/

/*! \brief Check if an installation job for a given add-on is already queued up
* \param ID The ID of the add-on
* \return true if a job exists, false otherwise
*/
bool HasJob(const CStdString& ID) const;

void UpdateRepos(bool force = false, bool wait = false);

void OnJobComplete(unsigned int jobID, bool success, CJob* job);
Expand Down

0 comments on commit b76bab8

Please sign in to comment.