Improve 'rebuild index' under Windows: this often failed because of some

open files in the Xapian db (could not be deleted under windows).
Now only fails if a preview has been opened, and a GUI restart fixes the
situation.
This commit is contained in:
Jean-Francois Dockes
2018-01-20 11:59:00 +01:00
parent 5b35ecfe36
commit fd32872218
6 changed files with 54 additions and 12 deletions
+10
View File
@@ -58,6 +58,7 @@ using namespace std;
#include "rclinit.h"
#include "internfile.h"
#include "utf8fn.h"
#include "wipedir.h"
#ifdef RCL_USE_ASPELL
#include "rclaspell.h"
#endif
@@ -793,6 +794,15 @@ bool Db::open(OpenMode mode, OpenError *error)
case DbUpd:
case DbTrunc:
{
// Xapian is quite bad at erasing partial db which can
// occur because of open file deletion errors on
// Windows.
if (mode == DbTrunc) {
if (path_exists(path_cat(dir, "iamchert"))) {
wipedir(dir);
unlink(dir.c_str());
}
}
int action = (mode == DbUpd) ? Xapian::DB_CREATE_OR_OPEN :
Xapian::DB_CREATE_OR_OVERWRITE;
if (::access(dir.c_str(), 0) != 0) {