wininet: Added support for cache entries overwriting.
This commit is contained in:
parent
6935b7c73b
commit
8f2b0fdf52
|
@ -363,7 +363,7 @@ static void test_urlcacheA(void)
|
||||||
|
|
||||||
create_and_write_file(filenameA, &zero_byte, sizeof(zero_byte));
|
create_and_write_file(filenameA, &zero_byte, sizeof(zero_byte));
|
||||||
|
|
||||||
ret = CommitUrlCacheEntry(TEST_URL1, NULL, filetime_zero, filetime_zero, NORMAL_CACHE_ENTRY|URLHISTORY_CACHE_ENTRY, NULL, 0, "html", NULL);
|
ret = CommitUrlCacheEntry(TEST_URL1, NULL, filetime_zero, filetime_zero, NORMAL_CACHE_ENTRY, NULL, 0, "html", NULL);
|
||||||
ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
|
ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
|
||||||
cbCacheEntryInfo = 0;
|
cbCacheEntryInfo = 0;
|
||||||
ret = GetUrlCacheEntryInfo(TEST_URL1, NULL, &cbCacheEntryInfo);
|
ret = GetUrlCacheEntryInfo(TEST_URL1, NULL, &cbCacheEntryInfo);
|
||||||
|
@ -377,6 +377,7 @@ static void test_urlcacheA(void)
|
||||||
"expected zero ExpireTime\n");
|
"expected zero ExpireTime\n");
|
||||||
ok(!memcmp(&lpCacheEntryInfo->LastModifiedTime, &filetime_zero, sizeof(FILETIME)),
|
ok(!memcmp(&lpCacheEntryInfo->LastModifiedTime, &filetime_zero, sizeof(FILETIME)),
|
||||||
"expected zero LastModifiedTime\n");
|
"expected zero LastModifiedTime\n");
|
||||||
|
todo_wine
|
||||||
ok(lpCacheEntryInfo->CacheEntryType == (NORMAL_CACHE_ENTRY|URLHISTORY_CACHE_ENTRY) ||
|
ok(lpCacheEntryInfo->CacheEntryType == (NORMAL_CACHE_ENTRY|URLHISTORY_CACHE_ENTRY) ||
|
||||||
broken(lpCacheEntryInfo->CacheEntryType == NORMAL_CACHE_ENTRY /* NT4/W2k */),
|
broken(lpCacheEntryInfo->CacheEntryType == NORMAL_CACHE_ENTRY /* NT4/W2k */),
|
||||||
"expected type NORMAL_CACHE_ENTRY|URLHISTORY_CACHE_ENTRY, got %08x\n",
|
"expected type NORMAL_CACHE_ENTRY|URLHISTORY_CACHE_ENTRY, got %08x\n",
|
||||||
|
@ -401,32 +402,27 @@ static void test_urlcacheA(void)
|
||||||
ret = GetUrlCacheEntryInfo(TEST_URL1, lpCacheEntryInfo2, &cbCacheEntryInfo);
|
ret = GetUrlCacheEntryInfo(TEST_URL1, lpCacheEntryInfo2, &cbCacheEntryInfo);
|
||||||
ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError());
|
ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError());
|
||||||
/* but it does change the time.. */
|
/* but it does change the time.. */
|
||||||
todo_wine
|
|
||||||
ok(memcmp(&lpCacheEntryInfo2->ExpireTime, &filetime_zero, sizeof(FILETIME)),
|
ok(memcmp(&lpCacheEntryInfo2->ExpireTime, &filetime_zero, sizeof(FILETIME)),
|
||||||
"expected positive ExpireTime\n");
|
"expected positive ExpireTime\n");
|
||||||
todo_wine
|
|
||||||
ok(memcmp(&lpCacheEntryInfo2->LastModifiedTime, &filetime_zero, sizeof(FILETIME)),
|
ok(memcmp(&lpCacheEntryInfo2->LastModifiedTime, &filetime_zero, sizeof(FILETIME)),
|
||||||
"expected positive LastModifiedTime\n");
|
"expected positive LastModifiedTime\n");
|
||||||
|
todo_wine
|
||||||
ok(lpCacheEntryInfo2->CacheEntryType == (NORMAL_CACHE_ENTRY|URLHISTORY_CACHE_ENTRY) ||
|
ok(lpCacheEntryInfo2->CacheEntryType == (NORMAL_CACHE_ENTRY|URLHISTORY_CACHE_ENTRY) ||
|
||||||
broken(lpCacheEntryInfo2->CacheEntryType == NORMAL_CACHE_ENTRY /* NT4/W2k */),
|
broken(lpCacheEntryInfo2->CacheEntryType == NORMAL_CACHE_ENTRY /* NT4/W2k */),
|
||||||
"expected type NORMAL_CACHE_ENTRY|URLHISTORY_CACHE_ENTRY, got %08x\n",
|
"expected type NORMAL_CACHE_ENTRY|URLHISTORY_CACHE_ENTRY, got %08x\n",
|
||||||
lpCacheEntryInfo2->CacheEntryType);
|
lpCacheEntryInfo2->CacheEntryType);
|
||||||
/* and set the headers. */
|
/* and set the headers. */
|
||||||
todo_wine
|
|
||||||
ok(lpCacheEntryInfo2->dwHeaderInfoSize == 19,
|
ok(lpCacheEntryInfo2->dwHeaderInfoSize == 19,
|
||||||
"expected headers size 19, got %d\n",
|
"expected headers size 19, got %d\n",
|
||||||
lpCacheEntryInfo2->dwHeaderInfoSize);
|
lpCacheEntryInfo2->dwHeaderInfoSize);
|
||||||
/* Hit rate gets incremented by 1 */
|
/* Hit rate gets incremented by 1 */
|
||||||
todo_wine
|
|
||||||
ok((lpCacheEntryInfo->dwHitRate + 1) == lpCacheEntryInfo2->dwHitRate,
|
ok((lpCacheEntryInfo->dwHitRate + 1) == lpCacheEntryInfo2->dwHitRate,
|
||||||
"HitRate not incremented by one on commit\n");
|
"HitRate not incremented by one on commit\n");
|
||||||
/* Last access time should be updated */
|
/* Last access time should be updated */
|
||||||
todo_wine
|
|
||||||
ok(!(lpCacheEntryInfo->LastAccessTime.dwHighDateTime == lpCacheEntryInfo2->LastAccessTime.dwHighDateTime &&
|
ok(!(lpCacheEntryInfo->LastAccessTime.dwHighDateTime == lpCacheEntryInfo2->LastAccessTime.dwHighDateTime &&
|
||||||
lpCacheEntryInfo->LastAccessTime.dwLowDateTime == lpCacheEntryInfo2->LastAccessTime.dwLowDateTime),
|
lpCacheEntryInfo->LastAccessTime.dwLowDateTime == lpCacheEntryInfo2->LastAccessTime.dwLowDateTime),
|
||||||
"Last accessed time was not updated by commit\n");
|
"Last accessed time was not updated by commit\n");
|
||||||
/* File extension should be unset */
|
/* File extension should be unset */
|
||||||
todo_wine
|
|
||||||
ok(lpCacheEntryInfo2->lpszFileExtension == NULL,
|
ok(lpCacheEntryInfo2->lpszFileExtension == NULL,
|
||||||
"Fileextension isn't unset: %s\n",
|
"Fileextension isn't unset: %s\n",
|
||||||
lpCacheEntryInfo2->lpszFileExtension);
|
lpCacheEntryInfo2->lpszFileExtension);
|
||||||
|
@ -519,16 +515,15 @@ static void test_urlcacheA(void)
|
||||||
ret = GetUrlCacheEntryInfo(TEST_URL, lpCacheEntryInfo, &cbCacheEntryInfo);
|
ret = GetUrlCacheEntryInfo(TEST_URL, lpCacheEntryInfo, &cbCacheEntryInfo);
|
||||||
ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError());
|
ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError());
|
||||||
/* with the previous entry type retained.. */
|
/* with the previous entry type retained.. */
|
||||||
|
todo_wine
|
||||||
ok(lpCacheEntryInfo->CacheEntryType & NORMAL_CACHE_ENTRY,
|
ok(lpCacheEntryInfo->CacheEntryType & NORMAL_CACHE_ENTRY,
|
||||||
"expected cache entry type NORMAL_CACHE_ENTRY, got %d (0x%08x)\n",
|
"expected cache entry type NORMAL_CACHE_ENTRY, got %d (0x%08x)\n",
|
||||||
lpCacheEntryInfo->CacheEntryType, lpCacheEntryInfo->CacheEntryType);
|
lpCacheEntryInfo->CacheEntryType, lpCacheEntryInfo->CacheEntryType);
|
||||||
/* and the headers overwritten.. */
|
/* and the headers overwritten.. */
|
||||||
todo_wine
|
|
||||||
ok(!lpCacheEntryInfo->dwHeaderInfoSize, "expected headers size 0, got %d\n",
|
ok(!lpCacheEntryInfo->dwHeaderInfoSize, "expected headers size 0, got %d\n",
|
||||||
lpCacheEntryInfo->dwHeaderInfoSize);
|
lpCacheEntryInfo->dwHeaderInfoSize);
|
||||||
HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo);
|
HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo);
|
||||||
/* and the previous filename shouldn't exist. */
|
/* and the previous filename shouldn't exist. */
|
||||||
todo_wine
|
|
||||||
check_file_not_exists(filenameA);
|
check_file_not_exists(filenameA);
|
||||||
check_file_exists(filenameA1);
|
check_file_exists(filenameA1);
|
||||||
|
|
||||||
|
@ -537,7 +532,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());
|
||||||
check_file_not_exists(filenameA);
|
check_file_not_exists(filenameA);
|
||||||
todo_wine
|
|
||||||
check_file_not_exists(filenameA1);
|
check_file_not_exists(filenameA1);
|
||||||
/* Just in case, clean up files */
|
/* Just in case, clean up files */
|
||||||
DeleteFileA(filenameA1);
|
DeleteFileA(filenameA1);
|
||||||
|
|
|
@ -2693,6 +2693,8 @@ static BOOL CommitUrlCacheEntryInternal(
|
||||||
LPSTR lpszUrlNameA = NULL;
|
LPSTR lpszUrlNameA = NULL;
|
||||||
LPSTR lpszFileExtensionA = NULL;
|
LPSTR lpszFileExtensionA = NULL;
|
||||||
char *pchLocalFileName = 0;
|
char *pchLocalFileName = 0;
|
||||||
|
DWORD hit_rate = 0;
|
||||||
|
DWORD exempt_delta = 0;
|
||||||
DWORD error;
|
DWORD error;
|
||||||
|
|
||||||
TRACE("(%s, %s, ..., ..., %x, %p, %d, %s, %s)\n",
|
TRACE("(%s, %s, ..., ..., %x, %p, %d, %s, %s)\n",
|
||||||
|
@ -2775,12 +2777,9 @@ static BOOL CommitUrlCacheEntryInternal(
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
FIXME("entry already in cache - don't know what to do!\n");
|
hit_rate = pUrlEntry->dwHitRate;
|
||||||
/*
|
exempt_delta = pUrlEntry->dwExemptDelta;
|
||||||
* SetLastError(ERROR_FILE_NOT_FOUND);
|
DeleteUrlCacheEntryInternal(pContainer, pHeader, pHashEntry);
|
||||||
* return FALSE;
|
|
||||||
*/
|
|
||||||
goto cleanup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lpszLocalFileName)
|
if (lpszLocalFileName)
|
||||||
|
@ -2861,14 +2860,13 @@ static BOOL CommitUrlCacheEntryInternal(
|
||||||
pUrlEntry->CacheDir = cDirectory;
|
pUrlEntry->CacheDir = cDirectory;
|
||||||
pUrlEntry->CacheEntryType = CacheEntryType;
|
pUrlEntry->CacheEntryType = CacheEntryType;
|
||||||
pUrlEntry->dwHeaderInfoSize = dwHeaderSize;
|
pUrlEntry->dwHeaderInfoSize = dwHeaderSize;
|
||||||
if (CacheEntryType & STICKY_CACHE_ENTRY)
|
if ((CacheEntryType & STICKY_CACHE_ENTRY) && !exempt_delta)
|
||||||
{
|
{
|
||||||
/* Sticky entries have a default exempt time of one day */
|
/* Sticky entries have a default exempt time of one day */
|
||||||
pUrlEntry->dwExemptDelta = 86400;
|
exempt_delta = 86400;
|
||||||
}
|
}
|
||||||
else
|
pUrlEntry->dwExemptDelta = exempt_delta;
|
||||||
pUrlEntry->dwExemptDelta = 0;
|
pUrlEntry->dwHitRate = hit_rate+1;
|
||||||
pUrlEntry->dwHitRate = 0;
|
|
||||||
pUrlEntry->dwOffsetFileExtension = dwOffsetFileExtension;
|
pUrlEntry->dwOffsetFileExtension = dwOffsetFileExtension;
|
||||||
pUrlEntry->dwOffsetHeaderInfo = dwOffsetHeader;
|
pUrlEntry->dwOffsetHeaderInfo = dwOffsetHeader;
|
||||||
pUrlEntry->dwOffsetLocalName = dwOffsetLocalFileName;
|
pUrlEntry->dwOffsetLocalName = dwOffsetLocalFileName;
|
||||||
|
|
Loading…
Reference in New Issue