From 64808b264688f0ae72aa8c710d810e3e8fd3b04e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20H=C3=A4rer?= Date: Fri, 5 Jan 2024 00:25:19 +0100 Subject: CTextureCache: Fix ClearCachedImage The passed in url wasn't "unwrapped" like for all other *Image member functions. This resulted in cached images not being cleared using the same url used for caching. (cherry picked from commit a6bc5237e8b9a327fe563f5a802620a930e2c1a6) --- xbmc/TextureCache.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xbmc/TextureCache.cpp b/xbmc/TextureCache.cpp index beca7cf9fd..6eeb098f8f 100644 --- a/xbmc/TextureCache.cpp +++ b/xbmc/TextureCache.cpp @@ -203,9 +203,10 @@ bool CTextureCache::CacheImage(const std::string &image, CTextureDetails &detail return !path.empty(); } -void CTextureCache::ClearCachedImage(const std::string &url, bool deleteSource /*= false */) +void CTextureCache::ClearCachedImage(const std::string& image, bool deleteSource /*= false */) { //! @todo This can be removed when the texture cache covers everything. + const std::string url = CTextureUtils::UnwrapImageURL(image); std::string path = deleteSource ? url : ""; std::string cachedFile; if (ClearCachedTexture(url, cachedFile)) -- cgit v1.2.3 From 70caaa44631829c784ca0d8d79d3e07bb4259cd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20H=C3=A4rer?= Date: Fri, 5 Jan 2024 00:38:11 +0100 Subject: CImageFile: Remove missing thumbs from CTextureCache If someone deletes the ~/.kodi/userdata/Thumbnails folder but not the TexturesXX.db then CImageFile wouldn't cache the image again and loading of the image fails, e.g. when using the JSON API to load album art via CHTTPImageHandler. By removing the entry from the CTextureCache and continung the current operation can succeed and the image will simply get cached again the next time it is opened. (cherry picked from commit 9f02ffd0ae693dcdcd5d6e8bb715134e8efc3803) --- xbmc/filesystem/ImageFile.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/xbmc/filesystem/ImageFile.cpp b/xbmc/filesystem/ImageFile.cpp index 969150975b..bb1e23acd2 100644 --- a/xbmc/filesystem/ImageFile.cpp +++ b/xbmc/filesystem/ImageFile.cpp @@ -45,7 +45,13 @@ bool CImageFile::Exists(const CURL& url) std::string cachedFile = CServiceBroker::GetTextureCache()->CheckCachedImage(url.Get(), needsRecaching); if (!cachedFile.empty()) - return CFile::Exists(cachedFile, false); + { + if (CFile::Exists(cachedFile, false)) + return true; + else + // Remove from cache so it gets cached again on next Open() + CServiceBroker::GetTextureCache()->ClearCachedImage(url.Get()); + } // need to check if the original can be cached on demand and that the file exists if (!CTextureCache::CanCacheImageURL(url)) -- cgit v1.2.3