As I think, the code you were surprised to see was a fix for this issue:

http://www.mail-archive.com/sqlite-users@sqlite.org/msg35864.html

as Jeremy Spiegel in that post wrote

> when I try calling DeleteFileW on a file with a handle open on
> that file, I see DeleteFileW returning 1 (success) and I see
> GetFileAttributesW returning INVALID_FILE_ATTRIBUTES, I think because
> even though the file still exists it is in a "delete pending" state.

So your variant was no longer sufficient as I suppose to address this
problem. As I see your code relies on DeleteFile return value thorughly.

I just can add that new problems with DeleteFile can appear recently with
introducing Windows 7. I'm not sure but once I saw a strange failure on a
system with Windows 7 and Microsoft Security Essentials installed (so at
least one candidate for "me-to" accessing any new file) when rollback failed
leaving -journal file existing and getting disk i/o error on the first
sqlite3_prepare after this rollback. But still I'm not sure it's related to
winDelete .


Max


On Thu, Jan 14, 2010 at 9:04 PM, Dave Dyer <dd...@real-me.net> wrote:

>
> There is a known problem, at least with NTFS, that deleting the
> journal file fails unexpectedly, resulting in sqlite3_cantopen.
> I believe I'm the one who originally reported this problem,
> but the installed solution isn't quite what I recommended.
>
> I'm not sure what OS/File System you are using, but something
> analogous may be going on for you.
>
> In "winDelete", the delete code in the released version is
>
>  if( isNT() ){
>    do{
>      DeleteFileW(zConverted);
>    }while(   (   ((rc = GetFileAttributesW(zConverted)) !=
> INVALID_FILE_ATTRIBUTES)
>               || ((error = GetLastError()) == ERROR_ACCESS_DENIED))
>           && (++cnt < MX_DELETION_ATTEMPTS)
>           && (Sleep(100), 1) );
>
>
>
> The code I"m using is
>
>  if( isNT() ){
>    do{
>      rc = DeleteFileW(zConverted);
>          if(rc==0)
>          {     long attr = GetFileAttributesW(zConverted);
>                if(attr==0xffffffff) { rc=1; }          // ok as long as
> sombody deleted it
>          }
>    }while( rc==0
>            && (cnt++ < MX_DELETION_ATTEMPTS)
>                        && (Sleep(100), 1) );
>
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to