Hi, I've compiled xapian 1.0.9 (core and buildings) on Windows Xp, using Lemur's nmake files[1]. I'm trying to use acts_as_xapian [2] on RubyOnRails, but I'm facing a problem with the rebuild index process. 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. 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. Is this correct or I'm missing something? 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. How can I make Xapian::WritableDatabase to release (close) the files it is using? Can I do that via Ruby, or diving into the code is needed? thanks pietro [1] http://lemurconsulting.com/Products/Xapian/Overview.shtml [2] http://github.com/frabcus/acts_as_xapian/tree/master
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