add updateable flag to AddCachedTexture, and set lasthashcheck empty if the flag...
authorJonathan Marshall <jmarshall@never.you.mind>
Fri, 6 Apr 2012 07:17:49 +0000 (19:17 +1200)
committerJonathan Marshall <jmarshall@never.you.mind>
Wed, 2 May 2012 03:20:49 +0000 (15:20 +1200)
xbmc/TextureCache.cpp
xbmc/TextureCache.h
xbmc/TextureDatabase.cpp
xbmc/TextureDatabase.h

index 7127731..27bc024 100644 (file)
@@ -162,7 +162,7 @@ CStdString CTextureCache::CacheImageFile(const CStdString &url)
   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);
@@ -229,10 +229,10 @@ bool CTextureCache::GetCachedTexture(const CStdString &url, CStdString &cachedUR
   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)
@@ -262,7 +262,7 @@ void CTextureCache::OnJobComplete(unsigned int jobID, bool success, CJob *job)
   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)));
index 1a739b6..4b31675 100644 (file)
@@ -146,9 +146,10 @@ public:
    \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
index 9d7a4f8..f78aee8 100644 (file)
@@ -149,7 +149,7 @@ bool CTextureDatabase::GetCachedTexture(const CStdString &url, CStdString &cache
       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
@@ -166,7 +166,7 @@ bool CTextureDatabase::GetCachedTexture(const CStdString &url, CStdString &cache
   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
   {
@@ -174,7 +174,7 @@ bool CTextureDatabase::AddCachedTexture(const CStdString &url, const CStdString
     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());
index b1f6255..f02781e 100644 (file)
@@ -31,7 +31,7 @@ public:
   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