would appreciate any confirmation that it works for you :)

On 7/30/08, Jeremy Spiegel <[EMAIL PROTECTED]> wrote:
>
> Shane,
>
> Just saw the checkin for the fix.  Thanks!
>
> :) Jeremy
>
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Shane Harrelson
> Sent: Wednesday, July 30, 2008 8:38 AM
> To: General Discussion of SQLite Database
> Subject: Re: [sqlite] winDelete retry-on-failure functionality isn't
> working
>
> GetFileAttributes() returns INVALID_FILE_ATTRIBUTES with an error of
> ERROR_ACCESS_DENIED if the file is in a "pending delete" state.  I'll
> update
> the retry logic in os_win.c in winDelete() to add this additional check.
> I
> believe that should improve the situation (as long as the other
> application
> which has the db journal file temporarily open closes it in the
> MX_DELETION_ATTEMPTS * 100ms time frame.)
>
> Of course, ERROR_ACCESS_DENIED can also be returned if you have
> insufficient
> privileges to access the file, but I don't think retrying the delete in
> this
> situation is bad either.
>
> The return should also be modified to return SQLITE_OK only when
> GetFileAttributes() returns INVALID_FILE_ATTRIBUTES with an error of
> ERROR_FILE_NOT_FOUND.  I'll make this change as well.
>
> HTH.
> -Shane
>
>
> On 7/29/08, Jeremy Spiegel <[EMAIL PROTECTED]> wrote:
> >
> > Hi,
> >
> > winDelete in os_win.c has retry functionality to try multiple times to
> > delete a file if a virus scanner or indexing program has a handle open
> > on that file.  We've seen SQLite failures that have been tracked down
> to
> > other apps temporarily opening our db journal files, so we believe
> that
> > the retry behavior could be very valuable to us.
> >
> > In order to check for failure, winDelete checks that DeleteFileW
> returns
> > zero and that GetFileAttributesW doesn't return
> INVALID_FILE_ATTRIBUTES.
> > However, 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.
> >
> > The code below illustrates the problem.  Thanks for any help you can
> > provide!
> >
> > :) Jeremy Spiegel
> >
> >
> > #include <stdio.h>
> > #include <tchar.h>
> > #include <windows.h>
> >
> > int _tmain(int argc, _TCHAR* argv[])
> > {
> >        DWORD dwDesiredAccess = GENERIC_READ | GENERIC_WRITE;
> >        DWORD dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE |
> > FILE_SHARE_DELETE;
> >        DWORD dwCreationDisposition = OPEN_ALWAYS;
> >        DWORD dwFlagsAndAttributes = FILE_ATTRIBUTE_TEMPORARY
> >                | FILE_ATTRIBUTE_HIDDEN
> >                | FILE_FLAG_DELETE_ON_CLOSE
> >                | FILE_FLAG_RANDOM_ACCESS;
> >
> >        HANDLE h = CreateFileW(L"c:\\test.txt",
> >                dwDesiredAccess,
> >                dwShareMode,
> >                NULL,
> >                dwCreationDisposition,
> >                dwFlagsAndAttributes,
> >                NULL
> >                );
> >
> >        if( h==INVALID_HANDLE_VALUE )
> >                printf("error\n");
> >
> >        int rc = DeleteFileW( L"c:\\test.txt" );
> >        if ( rc == 0 )
> >                printf("DeleteFileW failed\n");
> >
> >        if ( GetFileAttributesW( L"c:\\test.txt" ) != 0xffffffff )
> >                printf( "File still exists\n");
> >
> >        HANDLE h2 = CreateFileW(L"c:\\test.txt",
> >                dwDesiredAccess,
> >                dwShareMode,
> >                NULL,
> >                dwCreationDisposition,
> >                dwFlagsAndAttributes,
> >                NULL
> >                );
> >
> >        if ( h2 == INVALID_HANDLE_VALUE )
> >                printf( "Error: 0x%x", GetLastError() );
> >
> >        CloseHandle(h);
> >        return 0;
> > }
> > _______________________________________________
> > 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
> _______________________________________________
> 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