Skip to content
This repository
Browse code

Merge pull request #2192 from DasMarx/cacheFixes

Cache fixes, e.g. after pathsubstituion
  • Loading branch information...
commit 65fcfa63944e4ed6f5f7971ffc8257e5b5423eac 2 parents 1358020 + d7e209a
authored April 06, 2013
6  xbmc/filesystem/Directory.cpp
@@ -133,14 +133,14 @@ bool CDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items, c
133 133
       return false;
134 134
 
135 135
     // check our cache for this path
136  
-    if (g_directoryCache.GetDirectory(strPath, items, (hints.flags & DIR_FLAG_READ_CACHE) == DIR_FLAG_READ_CACHE))
  136
+    if (g_directoryCache.GetDirectory(realPath, items, (hints.flags & DIR_FLAG_READ_CACHE) == DIR_FLAG_READ_CACHE))
137 137
       items.SetPath(strPath);
138 138
     else
139 139
     {
140 140
       // need to clear the cache (in case the directory fetch fails)
141 141
       // and (re)fetch the folder
142 142
       if (!(hints.flags & DIR_FLAG_BYPASS_CACHE))
143  
-        g_directoryCache.ClearDirectory(strPath);
  143
+        g_directoryCache.ClearDirectory(realPath);
144 144
 
145 145
       pDirectory->SetFlags(hints.flags);
146 146
 
@@ -198,7 +198,7 @@ bool CDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items, c
198 198
 
199 199
       // cache the directory, if necessary
200 200
       if (!(hints.flags & DIR_FLAG_BYPASS_CACHE))
201  
-        g_directoryCache.SetDirectory(strPath, items, pDirectory->GetCacheType(strPath));
  201
+        g_directoryCache.SetDirectory(realPath, items, pDirectory->GetCacheType(strPath));
202 202
     }
203 203
 
204 204
     // now filter for allowed files
16  xbmc/filesystem/DirectoryCache.cpp
@@ -63,7 +63,7 @@ bool CDirectoryCache::GetDirectory(const CStdString& strPath, CFileItemList &ite
63 63
 {
64 64
   CSingleLock lock (m_cs);
65 65
 
66  
-  CStdString storedPath = URIUtils::SubstitutePath(strPath);
  66
+  CStdString storedPath = strPath;
67 67
   URIUtils::RemoveSlashAtEnd(storedPath);
68 68
 
69 69
   ciCache i = m_cache.find(storedPath);
@@ -102,7 +102,7 @@ void CDirectoryCache::SetDirectory(const CStdString& strPath, const CFileItemLis
102 102
   // this is the best solution for now.
103 103
   CSingleLock lock (m_cs);
104 104
 
105  
-  CStdString storedPath = URIUtils::SubstitutePath(strPath);
  105
+  CStdString storedPath = strPath;
106 106
   URIUtils::RemoveSlashAtEnd(storedPath);
107 107
 
108 108
   ClearDirectory(storedPath);
@@ -126,7 +126,7 @@ void CDirectoryCache::ClearDirectory(const CStdString& strPath)
126 126
 {
127 127
   CSingleLock lock (m_cs);
128 128
 
129  
-  CStdString storedPath = URIUtils::SubstitutePath(strPath);
  129
+  CStdString storedPath = strPath;
130 130
   URIUtils::RemoveSlashAtEnd(storedPath);
131 131
 
132 132
   iCache i = m_cache.find(storedPath);
@@ -138,7 +138,7 @@ void CDirectoryCache::ClearSubPaths(const CStdString& strPath)
138 138
 {
139 139
   CSingleLock lock (m_cs);
140 140
 
141  
-  CStdString storedPath = URIUtils::SubstitutePath(strPath);
  141
+  CStdString storedPath = strPath;
142 142
   URIUtils::RemoveSlashAtEnd(storedPath);
143 143
 
144 144
   iCache i = m_cache.begin();
@@ -175,11 +175,11 @@ bool CDirectoryCache::FileExists(const CStdString& strFile, bool& bInCache)
175 175
   CSingleLock lock (m_cs);
176 176
   bInCache = false;
177 177
 
178  
-  CStdString strPath;
179  
-  URIUtils::GetDirectory(strFile, strPath);
180  
-  URIUtils::RemoveSlashAtEnd(strPath);
  178
+  CStdString storedPath;
  179
+  URIUtils::GetDirectory(strFile, storedPath);
  180
+  URIUtils::RemoveSlashAtEnd(storedPath);
181 181
 
182  
-  ciCache i = m_cache.find(strPath);
  182
+  ciCache i = m_cache.find(storedPath);
183 183
   if (i != m_cache.end())
184 184
   {
185 185
     bInCache = true;
18  xbmc/filesystem/File.cpp
@@ -215,7 +215,7 @@ bool CFile::Open(const CStdString& strFileName, unsigned int flags)
215 215
   try
216 216
   {
217 217
     bool bPathInCache;
218  
-    CURL url2(strFileName);
  218
+    CURL url2(URIUtils::SubstitutePath(strFileName));
219 219
     if (url2.GetProtocol() == "apk")
220 220
       url2.SetOptions("");
221 221
     if (url2.GetProtocol() == "zip")
@@ -312,13 +312,14 @@ bool CFile::OpenForWrite(const CStdString& strFileName, bool bOverWrite)
312 312
 {
313 313
   try
314 314
   {
315  
-    CURL url(URIUtils::SubstitutePath(strFileName));
  315
+	CStdString storedFileName = URIUtils::SubstitutePath(strFileName);
  316
+    CURL url(storedFileName);
316 317
 
317 318
     m_pFile = CFileFactory::CreateLoader(url);
318 319
     if (m_pFile && m_pFile->OpenForWrite(url, bOverWrite))
319 320
     {
320 321
       // add this file to our directory cache (if it's stored)
321  
-      g_directoryCache.AddFile(strFileName);
  322
+      g_directoryCache.AddFile(storedFileName);
322 323
       return true;
323 324
     }
324 325
     return false;
@@ -334,7 +335,7 @@ bool CFile::OpenForWrite(const CStdString& strFileName, bool bOverWrite)
334 335
 
335 336
 bool CFile::Exists(const CStdString& strFileName, bool bUseCache /* = true */)
336 337
 {
337  
-  CURL url;
  338
+  CURL url = URIUtils::SubstitutePath(strFileName);;
338 339
   
339 340
   try
340 341
   {
@@ -344,13 +345,12 @@ bool CFile::Exists(const CStdString& strFileName, bool bUseCache /* = true */)
344 345
     if (bUseCache)
345 346
     {
346 347
       bool bPathInCache;
347  
-      if (g_directoryCache.FileExists(strFileName, bPathInCache) )
  348
+      if (g_directoryCache.FileExists(url.Get(), bPathInCache) )
348 349
         return true;
349 350
       if (bPathInCache)
350 351
         return false;
351 352
     }
352 353
 
353  
-    url = URIUtils::SubstitutePath(strFileName);
354 354
     auto_ptr<IFile> pFile(CFileFactory::CreateLoader(url));
355 355
     if (!pFile.get())
356 356
       return false;
@@ -718,7 +718,7 @@ bool CFile::Delete(const CStdString& strFileName)
718 718
 
719 719
     if(pFile->Delete(url))
720 720
     {
721  
-      g_directoryCache.ClearFile(strFileName);
  721
+      g_directoryCache.ClearFile(url.Get());
722 722
       return true;
723 723
     }
724 724
   }
@@ -745,8 +745,8 @@ bool CFile::Rename(const CStdString& strFileName, const CStdString& strNewFileNa
745 745
 
746 746
     if(pFile->Rename(url, urlnew))
747 747
     {
748  
-      g_directoryCache.ClearFile(strFileName);
749  
-      g_directoryCache.ClearFile(strNewFileName);
  748
+      g_directoryCache.ClearFile(url.Get());
  749
+      g_directoryCache.AddFile(urlnew.Get());
750 750
       return true;
751 751
     }
752 752
   }

0 notes on commit 65fcfa6

Please sign in to comment.
Something went wrong with that request. Please try again.