[Xapian-discuss] ruby xapian bindings and windows

Olly Betts olly at survex.com
Wed Nov 19 10:16:56 GMT 2008


On Wed, Nov 19, 2008 at 10:16:07AM +0100, Pietro Giorgianni wrote:
> in acts_as_xapian, to rebuild the index, a new
> Xapian::WritableDatabase is created with a different path, then
> flush() is invoked; lastly, the new path is renamed to the old one.
> 
> At this point, the operation fails on Windows, since the flush()
> method doesn't close the involved files, and on Windows renaming or
> deleting open files is forbidden.

Yes, what acts_as_xapian is doing isn't portable.

> I tried to take a look at the Xapian API Documentation, but it seems
> to me that only the destructor of Xapian::WritableDatabase does close
> the files.

Yes.

> I suppose that creating a new physical index rather than overwriting
> the old one, is the right way to do stuff, so now I'm looking for a
> way to make things work as painless as I can.

Make the "live" database a stub database file which points at the
current database you want to use.  Then to switch in the new database
you just need to write a new stub database file and replace the existing
one with it.  It won't then matter if the new database is still open.

Cheers,
    Olly



More information about the Xapian-discuss mailing list