1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-14 00:22:38 +03:00

Revise logic in winDelete to check the file prior to attempting to delete it.

FossilOrigin-Name: 36f11acc531a524407e03c797a6a1bcf88bad809
This commit is contained in:
mistachkin
2011-07-12 14:02:47 +00:00
parent a32ad8434e
commit dc9e9587c6
3 changed files with 19 additions and 11 deletions

View File

@@ -426,7 +426,9 @@ static int retryIoerr(int *pnRetry){
return 0;
}
e = GetLastError();
if( e==ERROR_LOCK_VIOLATION || e==ERROR_SHARING_VIOLATION ){
if( e==ERROR_ACCESS_DENIED ||
e==ERROR_LOCK_VIOLATION ||
e==ERROR_SHARING_VIOLATION ){
Sleep(SQLITE_WIN32_IOERR_RETRY_DELAY*(1+*pnRetry));
++*pnRetry;
return 1;
@@ -2388,14 +2390,20 @@ static int winDelete(
return SQLITE_NOMEM;
}
if( isNT() ){
while( (rc = DeleteFileW(zConverted))!=0 || retryIoerr(&cnt) ){}
rc = 1;
while( GetFileAttributesW(zConverted)!=INVALID_FILE_ATTRIBUTES &&
(rc = DeleteFileW(zConverted))==0 && retryIoerr(&cnt) ){}
rc = rc ? SQLITE_OK : SQLITE_ERROR;
/* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed.
** Since the ASCII version of these Windows API do not exist for WINCE,
** it's important to not reference them for WINCE builds.
*/
#if SQLITE_OS_WINCE==0
}else{
while( (rc = DeleteFileW(zConverted))!=0 || retryIoerr(&cnt) ){}
rc = 1;
while( GetFileAttributesA(zConverted)!=INVALID_FILE_ATTRIBUTES &&
(rc = DeleteFileA(zConverted))==0 && retryIoerr(&cnt) ){}
rc = rc ? SQLITE_OK : SQLITE_ERROR;
#endif
}
if( rc ){