Piotr Caban : wininet: Delete file when cache entry is deleted.

Alexandre Julliard julliard at winehq.org
Tue Sep 18 14:04:30 CDT 2012


Module: wine
Branch: master
Commit: 359ed3382442db00c2bf55dc958629d812e3e6be
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=359ed3382442db00c2bf55dc958629d812e3e6be

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Tue Sep 18 14:43:23 2012 +0200

wininet: Delete file when cache entry is deleted.

---

 dlls/wininet/tests/urlcache.c |    5 -----
 dlls/wininet/urlcache.c       |   19 +++++++++++++------
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/dlls/wininet/tests/urlcache.c b/dlls/wininet/tests/urlcache.c
index 12827e9..4238c60 100644
--- a/dlls/wininet/tests/urlcache.c
+++ b/dlls/wininet/tests/urlcache.c
@@ -481,7 +481,6 @@ static void test_urlcacheA(void)
 
     SetLastError(0xdeadbeef);
     ret = DeleteFile(filenameA);
-    todo_wine
     ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "local file should no longer exist\n");
 
     /* Creating two entries with the same URL */
@@ -537,7 +536,6 @@ static void test_urlcacheA(void)
     {
         ret = pDeleteUrlCacheEntryA(TEST_URL);
         ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError());
-        todo_wine
         check_file_not_exists(filenameA);
         todo_wine
         check_file_not_exists(filenameA1);
@@ -595,7 +593,6 @@ static void test_urlcacheA(void)
         /* By unlocking the already-deleted cache entry, the file associated
          * with it is deleted..
          */
-        todo_wine
         check_file_not_exists(filenameA);
         /* (just in case, delete file) */
         DeleteFileA(filenameA);
@@ -692,7 +689,6 @@ static void test_urlcacheA(void)
         ret = pDeleteUrlCacheEntryA(TEST_URL);
         ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError());
         /* When explicitly deleting the cache entry, the file is also deleted */
-        todo_wine
         check_file_not_exists(filenameA);
     }
     /* Test once again, setting the exempt delta via SetUrlCacheEntryInfo */
@@ -760,7 +756,6 @@ static void test_urlcacheA(void)
     {
         ret = pDeleteUrlCacheEntryA(TEST_URL);
         ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError());
-        todo_wine
         check_file_not_exists(filenameA);
     }
 }
diff --git a/dlls/wininet/urlcache.c b/dlls/wininet/urlcache.c
index 0536093..1b62fda 100644
--- a/dlls/wininet/urlcache.c
+++ b/dlls/wininet/urlcache.c
@@ -2175,11 +2175,13 @@ BOOL WINAPI RetrieveUrlCacheEntryFileW(
     return TRUE;
 }
 
-static BOOL DeleteUrlCacheEntryInternal(LPURLCACHE_HEADER pHeader,
-        struct _HASH_ENTRY *pHashEntry)
+static BOOL DeleteUrlCacheEntryInternal(const URLCACHECONTAINER * pContainer,
+        LPURLCACHE_HEADER pHeader, struct _HASH_ENTRY *pHashEntry)
 {
     CACHEFILE_ENTRY * pEntry;
     URL_CACHEFILE_ENTRY * pUrlEntry;
+    WCHAR path[MAX_PATH];
+    LONG path_size = sizeof(path);
 
     pEntry = (CACHEFILE_ENTRY *)((LPBYTE)pHeader + pHashEntry->dwOffsetEntry);
     if (pEntry->dwSignature != URL_SIGNATURE)
@@ -2220,8 +2222,13 @@ static BOOL DeleteUrlCacheEntryInternal(LPURLCACHE_HEADER pHeader,
             pHeader->CacheUsage.QuadPart = 0;
     }
 
-    URLCache_DeleteEntry(pHeader, pEntry);
+    if (pUrlEntry->dwOffsetLocalName && URLCache_LocalFileNameToPathW(pContainer, pHeader,
+                (LPCSTR)pUrlEntry+pUrlEntry->dwOffsetLocalName, pUrlEntry->CacheDir, path, &path_size))
+    {
+        DeleteFileW(path);
+    }
 
+    URLCache_DeleteEntry(pHeader, pEntry);
     URLCache_DeleteEntryFromHash(pHashEntry);
     return TRUE;
 }
@@ -2297,7 +2304,7 @@ BOOL WINAPI UnlockUrlCacheEntryFileA(
     {
         URLCache_HashEntrySetFlags(pHashEntry, HASHTABLE_URL);
         if (pUrlEntry->CacheEntryType & PENDING_DELETE_CACHE_ENTRY)
-            DeleteUrlCacheEntryInternal(pHeader, pHashEntry);
+            DeleteUrlCacheEntryInternal(pContainer, pHeader, pHashEntry);
     }
 
     URLCacheContainer_UnlockIndex(pContainer, pHeader);
@@ -3241,7 +3248,7 @@ BOOL WINAPI DeleteUrlCacheEntryA(LPCSTR lpszUrlName)
         return FALSE;
     }
 
-    ret = DeleteUrlCacheEntryInternal(pHeader, pHashEntry);
+    ret = DeleteUrlCacheEntryInternal(pContainer, pHeader, pHashEntry);
 
     URLCacheContainer_UnlockIndex(pContainer, pHeader);
 
@@ -3301,7 +3308,7 @@ BOOL WINAPI DeleteUrlCacheEntryW(LPCWSTR lpszUrlName)
         return FALSE;
     }
 
-    ret = DeleteUrlCacheEntryInternal(pHeader, pHashEntry);
+    ret = DeleteUrlCacheEntryInternal(pContainer, pHeader, pHashEntry);
 
     URLCacheContainer_UnlockIndex(pContainer, pHeader);
     heap_free(urlA);




More information about the wine-cvs mailing list