CTextureCacheJob job(url, "");
if (job.DoWork() && !job.m_hash.IsEmpty())
{
- AddCachedTexture(url, job.m_cacheFile, job.m_hash);
+ AddCachedTexture(url, job.m_cacheFile, job.m_hash, job.m_updateable);
if (g_advancedSettings.m_useDDSFanart && !job.m_cacheFile.IsEmpty())
AddJob(new CTextureDDSJob(GetCachedPath(job.m_cacheFile)));
return GetCachedPath(job.m_cacheFile);
return m_database.GetCachedTexture(url, cachedURL, cachedHash);
}
-bool CTextureCache::AddCachedTexture(const CStdString &url, const CStdString &cachedURL, const CStdString &hash)
+bool CTextureCache::AddCachedTexture(const CStdString &url, const CStdString &cachedURL, const CStdString &hash, bool updateable)
{
CSingleLock lock(m_databaseSection);
- return m_database.AddCachedTexture(url, cachedURL, hash);
+ return m_database.AddCachedTexture(url, cachedURL, hash, updateable);
}
bool CTextureCache::ClearCachedTexture(const CStdString &url, CStdString &cachedURL)
if (strcmp(job->GetType(), "cacheimage") == 0 && success)
{
CTextureCacheJob *cacheJob = (CTextureCacheJob *)job;
- AddCachedTexture(cacheJob->m_url, cacheJob->m_cacheFile, cacheJob->m_hash);
+ AddCachedTexture(cacheJob->m_url, cacheJob->m_cacheFile, cacheJob->m_hash, cacheJob->m_updateable);
// TODO: call back to the UI indicating that it can update it's image...
if (g_advancedSettings.m_useDDSFanart && !cacheJob->m_cacheFile.IsEmpty())
AddJob(new CTextureDDSJob(GetCachedPath(cacheJob->m_cacheFile)));
\param image url of the original image
\param cacheFile url of the cached image
\param hash hash of the original image
+ \param updateable whether this image is updateable
\return true if we successfully added to the database, false otherwise.
*/
- bool AddCachedTexture(const CStdString &image, const CStdString &cacheFile, const CStdString &hash);
+ bool AddCachedTexture(const CStdString &image, const CStdString &cacheFile, const CStdString &hash, bool updateable = false);
/*! \brief Export a (possibly) cached image to a file
\param image url of the original image
cacheFile = m_pDS->fv(1).get_asString();
CDateTime lastCheck;
lastCheck.SetFromDBDateTime(m_pDS->fv(2).get_asString());
- if (!lastCheck.IsValid() || lastCheck + CDateTimeSpan(1,0,0,0) < CDateTime::GetCurrentDateTime())
+ if (lastCheck.IsValid() && lastCheck + CDateTimeSpan(1,0,0,0) < CDateTime::GetCurrentDateTime())
imageHash = m_pDS->fv(3).get_asString();
m_pDS->close();
// update the use count
return false;
}
-bool CTextureDatabase::AddCachedTexture(const CStdString &url, const CStdString &cacheFile, const CStdString &imageHash)
+bool CTextureDatabase::AddCachedTexture(const CStdString &url, const CStdString &cacheFile, const CStdString &imageHash, bool updateable)
{
try
{
if (NULL == m_pDS.get()) return false;
CStdString cacheURL(cacheFile);
- CStdString date = CDateTime::GetCurrentDateTime().GetAsDBDateTime();
+ CStdString date = updateable ? CDateTime::GetCurrentDateTime().GetAsDBDateTime() : "";
CStdString sql = PrepareSQL("select id,cachedurl from texture where url='%s'", url.c_str());
m_pDS->query(sql.c_str());
virtual bool Open();
bool GetCachedTexture(const CStdString &originalURL, CStdString &cacheFile, CStdString &imageHash);
- bool AddCachedTexture(const CStdString &originalURL, const CStdString &cachedFile, const CStdString &imageHash = "");
+ bool AddCachedTexture(const CStdString &originalURL, const CStdString &cachedFile, const CStdString &imageHash = "", bool updateable = true);
bool ClearCachedTexture(const CStdString &originalURL, CStdString &cacheFile);
/*! \brief Invalidate a previously cached texture