Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #2192 from DasMarx/cacheFixes

Cache fixes, e.g. after pathsubstituion
  • Loading branch information...
commit 65fcfa63944e4ed6f5f7971ffc8257e5b5423eac 2 parents 1358020 + d7e209a
Arne Morten Kvarving authored
View
6 xbmc/filesystem/Directory.cpp
@@ -133,14 +133,14 @@ bool CDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items, c
return false;
// check our cache for this path
- if (g_directoryCache.GetDirectory(strPath, items, (hints.flags & DIR_FLAG_READ_CACHE) == DIR_FLAG_READ_CACHE))
+ if (g_directoryCache.GetDirectory(realPath, items, (hints.flags & DIR_FLAG_READ_CACHE) == DIR_FLAG_READ_CACHE))
items.SetPath(strPath);
else
{
// need to clear the cache (in case the directory fetch fails)
// and (re)fetch the folder
if (!(hints.flags & DIR_FLAG_BYPASS_CACHE))
- g_directoryCache.ClearDirectory(strPath);
+ g_directoryCache.ClearDirectory(realPath);
pDirectory->SetFlags(hints.flags);
@@ -198,7 +198,7 @@ bool CDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items, c
// cache the directory, if necessary
if (!(hints.flags & DIR_FLAG_BYPASS_CACHE))
- g_directoryCache.SetDirectory(strPath, items, pDirectory->GetCacheType(strPath));
+ g_directoryCache.SetDirectory(realPath, items, pDirectory->GetCacheType(strPath));
}
// now filter for allowed files
View
16 xbmc/filesystem/DirectoryCache.cpp
@@ -63,7 +63,7 @@ bool CDirectoryCache::GetDirectory(const CStdString& strPath, CFileItemList &ite
{
CSingleLock lock (m_cs);
- CStdString storedPath = URIUtils::SubstitutePath(strPath);
+ CStdString storedPath = strPath;
URIUtils::RemoveSlashAtEnd(storedPath);
ciCache i = m_cache.find(storedPath);
@@ -102,7 +102,7 @@ void CDirectoryCache::SetDirectory(const CStdString& strPath, const CFileItemLis
// this is the best solution for now.
CSingleLock lock (m_cs);
- CStdString storedPath = URIUtils::SubstitutePath(strPath);
+ CStdString storedPath = strPath;
URIUtils::RemoveSlashAtEnd(storedPath);
ClearDirectory(storedPath);
@@ -126,7 +126,7 @@ void CDirectoryCache::ClearDirectory(const CStdString& strPath)
{
CSingleLock lock (m_cs);
- CStdString storedPath = URIUtils::SubstitutePath(strPath);
+ CStdString storedPath = strPath;
URIUtils::RemoveSlashAtEnd(storedPath);
iCache i = m_cache.find(storedPath);
@@ -138,7 +138,7 @@ void CDirectoryCache::ClearSubPaths(const CStdString& strPath)
{
CSingleLock lock (m_cs);
- CStdString storedPath = URIUtils::SubstitutePath(strPath);
+ CStdString storedPath = strPath;
URIUtils::RemoveSlashAtEnd(storedPath);
iCache i = m_cache.begin();
@@ -175,11 +175,11 @@ bool CDirectoryCache::FileExists(const CStdString& strFile, bool& bInCache)
CSingleLock lock (m_cs);
bInCache = false;
- CStdString strPath;
- URIUtils::GetDirectory(strFile, strPath);
- URIUtils::RemoveSlashAtEnd(strPath);
+ CStdString storedPath;
+ URIUtils::GetDirectory(strFile, storedPath);
+ URIUtils::RemoveSlashAtEnd(storedPath);
- ciCache i = m_cache.find(strPath);
+ ciCache i = m_cache.find(storedPath);
if (i != m_cache.end())
{
bInCache = true;
View
18 xbmc/filesystem/File.cpp
@@ -215,7 +215,7 @@ bool CFile::Open(const CStdString& strFileName, unsigned int flags)
try
{
bool bPathInCache;
- CURL url2(strFileName);
+ CURL url2(URIUtils::SubstitutePath(strFileName));
if (url2.GetProtocol() == "apk")
url2.SetOptions("");
if (url2.GetProtocol() == "zip")
@@ -312,13 +312,14 @@ bool CFile::OpenForWrite(const CStdString& strFileName, bool bOverWrite)
{
try
{
- CURL url(URIUtils::SubstitutePath(strFileName));
+ CStdString storedFileName = URIUtils::SubstitutePath(strFileName);
+ CURL url(storedFileName);
m_pFile = CFileFactory::CreateLoader(url);
if (m_pFile && m_pFile->OpenForWrite(url, bOverWrite))
{
// add this file to our directory cache (if it's stored)
- g_directoryCache.AddFile(strFileName);
+ g_directoryCache.AddFile(storedFileName);
return true;
}
return false;
@@ -334,7 +335,7 @@ bool CFile::OpenForWrite(const CStdString& strFileName, bool bOverWrite)
bool CFile::Exists(const CStdString& strFileName, bool bUseCache /* = true */)
{
- CURL url;
+ CURL url = URIUtils::SubstitutePath(strFileName);;
try
{
@@ -344,13 +345,12 @@ bool CFile::Exists(const CStdString& strFileName, bool bUseCache /* = true */)
if (bUseCache)
{
bool bPathInCache;
- if (g_directoryCache.FileExists(strFileName, bPathInCache) )
+ if (g_directoryCache.FileExists(url.Get(), bPathInCache) )
return true;
if (bPathInCache)
return false;
}
- url = URIUtils::SubstitutePath(strFileName);
auto_ptr<IFile> pFile(CFileFactory::CreateLoader(url));
if (!pFile.get())
return false;
@@ -718,7 +718,7 @@ bool CFile::Delete(const CStdString& strFileName)
if(pFile->Delete(url))
{
- g_directoryCache.ClearFile(strFileName);
+ g_directoryCache.ClearFile(url.Get());
return true;
}
}
@@ -745,8 +745,8 @@ bool CFile::Rename(const CStdString& strFileName, const CStdString& strNewFileNa
if(pFile->Rename(url, urlnew))
{
- g_directoryCache.ClearFile(strFileName);
- g_directoryCache.ClearFile(strNewFileName);
+ g_directoryCache.ClearFile(url.Get());
+ g_directoryCache.AddFile(urlnew.Get());
return true;
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.