Commit 359ed338 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

wininet: Delete file when cache entry is deleted.

parent 7967f8be
...@@ -481,7 +481,6 @@ static void test_urlcacheA(void) ...@@ -481,7 +481,6 @@ static void test_urlcacheA(void)
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = DeleteFile(filenameA); ret = DeleteFile(filenameA);
todo_wine
ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "local file should no longer exist\n"); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "local file should no longer exist\n");
/* Creating two entries with the same URL */ /* Creating two entries with the same URL */
...@@ -537,7 +536,6 @@ static void test_urlcacheA(void) ...@@ -537,7 +536,6 @@ static void test_urlcacheA(void)
{ {
ret = pDeleteUrlCacheEntryA(TEST_URL); ret = pDeleteUrlCacheEntryA(TEST_URL);
ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError()); ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError());
todo_wine
check_file_not_exists(filenameA); check_file_not_exists(filenameA);
todo_wine todo_wine
check_file_not_exists(filenameA1); check_file_not_exists(filenameA1);
...@@ -595,7 +593,6 @@ static void test_urlcacheA(void) ...@@ -595,7 +593,6 @@ static void test_urlcacheA(void)
/* By unlocking the already-deleted cache entry, the file associated /* By unlocking the already-deleted cache entry, the file associated
* with it is deleted.. * with it is deleted..
*/ */
todo_wine
check_file_not_exists(filenameA); check_file_not_exists(filenameA);
/* (just in case, delete file) */ /* (just in case, delete file) */
DeleteFileA(filenameA); DeleteFileA(filenameA);
...@@ -692,7 +689,6 @@ static void test_urlcacheA(void) ...@@ -692,7 +689,6 @@ static void test_urlcacheA(void)
ret = pDeleteUrlCacheEntryA(TEST_URL); ret = pDeleteUrlCacheEntryA(TEST_URL);
ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError()); ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError());
/* When explicitly deleting the cache entry, the file is also deleted */ /* When explicitly deleting the cache entry, the file is also deleted */
todo_wine
check_file_not_exists(filenameA); check_file_not_exists(filenameA);
} }
/* Test once again, setting the exempt delta via SetUrlCacheEntryInfo */ /* Test once again, setting the exempt delta via SetUrlCacheEntryInfo */
...@@ -760,7 +756,6 @@ static void test_urlcacheA(void) ...@@ -760,7 +756,6 @@ static void test_urlcacheA(void)
{ {
ret = pDeleteUrlCacheEntryA(TEST_URL); ret = pDeleteUrlCacheEntryA(TEST_URL);
ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError()); ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError());
todo_wine
check_file_not_exists(filenameA); check_file_not_exists(filenameA);
} }
} }
......
...@@ -2175,11 +2175,13 @@ BOOL WINAPI RetrieveUrlCacheEntryFileW( ...@@ -2175,11 +2175,13 @@ BOOL WINAPI RetrieveUrlCacheEntryFileW(
return TRUE; return TRUE;
} }
static BOOL DeleteUrlCacheEntryInternal(LPURLCACHE_HEADER pHeader, static BOOL DeleteUrlCacheEntryInternal(const URLCACHECONTAINER * pContainer,
struct _HASH_ENTRY *pHashEntry) LPURLCACHE_HEADER pHeader, struct _HASH_ENTRY *pHashEntry)
{ {
CACHEFILE_ENTRY * pEntry; CACHEFILE_ENTRY * pEntry;
URL_CACHEFILE_ENTRY * pUrlEntry; URL_CACHEFILE_ENTRY * pUrlEntry;
WCHAR path[MAX_PATH];
LONG path_size = sizeof(path);
pEntry = (CACHEFILE_ENTRY *)((LPBYTE)pHeader + pHashEntry->dwOffsetEntry); pEntry = (CACHEFILE_ENTRY *)((LPBYTE)pHeader + pHashEntry->dwOffsetEntry);
if (pEntry->dwSignature != URL_SIGNATURE) if (pEntry->dwSignature != URL_SIGNATURE)
...@@ -2220,8 +2222,13 @@ static BOOL DeleteUrlCacheEntryInternal(LPURLCACHE_HEADER pHeader, ...@@ -2220,8 +2222,13 @@ static BOOL DeleteUrlCacheEntryInternal(LPURLCACHE_HEADER pHeader,
pHeader->CacheUsage.QuadPart = 0; 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); URLCache_DeleteEntryFromHash(pHashEntry);
return TRUE; return TRUE;
} }
...@@ -2297,7 +2304,7 @@ BOOL WINAPI UnlockUrlCacheEntryFileA( ...@@ -2297,7 +2304,7 @@ BOOL WINAPI UnlockUrlCacheEntryFileA(
{ {
URLCache_HashEntrySetFlags(pHashEntry, HASHTABLE_URL); URLCache_HashEntrySetFlags(pHashEntry, HASHTABLE_URL);
if (pUrlEntry->CacheEntryType & PENDING_DELETE_CACHE_ENTRY) if (pUrlEntry->CacheEntryType & PENDING_DELETE_CACHE_ENTRY)
DeleteUrlCacheEntryInternal(pHeader, pHashEntry); DeleteUrlCacheEntryInternal(pContainer, pHeader, pHashEntry);
} }
URLCacheContainer_UnlockIndex(pContainer, pHeader); URLCacheContainer_UnlockIndex(pContainer, pHeader);
...@@ -3241,7 +3248,7 @@ BOOL WINAPI DeleteUrlCacheEntryA(LPCSTR lpszUrlName) ...@@ -3241,7 +3248,7 @@ BOOL WINAPI DeleteUrlCacheEntryA(LPCSTR lpszUrlName)
return FALSE; return FALSE;
} }
ret = DeleteUrlCacheEntryInternal(pHeader, pHashEntry); ret = DeleteUrlCacheEntryInternal(pContainer, pHeader, pHashEntry);
URLCacheContainer_UnlockIndex(pContainer, pHeader); URLCacheContainer_UnlockIndex(pContainer, pHeader);
...@@ -3301,7 +3308,7 @@ BOOL WINAPI DeleteUrlCacheEntryW(LPCWSTR lpszUrlName) ...@@ -3301,7 +3308,7 @@ BOOL WINAPI DeleteUrlCacheEntryW(LPCWSTR lpszUrlName)
return FALSE; return FALSE;
} }
ret = DeleteUrlCacheEntryInternal(pHeader, pHashEntry); ret = DeleteUrlCacheEntryInternal(pContainer, pHeader, pHashEntry);
URLCacheContainer_UnlockIndex(pContainer, pHeader); URLCacheContainer_UnlockIndex(pContainer, pHeader);
heap_free(urlA); heap_free(urlA);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment