I am trying to manually index a folder in Thunderbird by using GlodaIndexer. What I do is following.
1. I open a new tab with the
document.getElementById("tabmail").openTab("chromeTab", {
chromePage: “indexWithGloda.html”,
});
2. The file indexWithGloda.html has a button with an onlick even that should start the indexing.
<html>
<head>
<script type="text/javascript">
function onClickStartIndexingWithGloda()
{
var inboxFolder = getInboxFolder(); // Find the inbox folder
GlodaMsgIndexer.indexFolder(inboxFolder, ["force"]);
var job = GlodaIndexer._indexQueue.pop();
GlodaMsgIndexer._worker_folderIndex(job);
}
function getInboxFolder() {
var inbox = null;
var accounts = [x for each (x in fixIterator(MailServices.accounts.accounts, Ci.nsIMsgAccount))].filter(function (x) x.incomingServer);
var server = accounts[0].incomingServer;
var folder = server.rootFolder;
var searchForInbox = function(folder) {
var isInbox = folder.getFlag(Ci.nsMsgFolderFlags.Inbox);
if (isInbox) {
inbox = folder;
}
else if (folder.hasSubFolders) {
for each (var subFolder in fixIterator(folder.subFolders, Ci.nsIMsgFolder))
searchForInbox(subFolder);
}
}
searchForInbox(folder);
return inbox;
}
</script>
</head>
<body>
<input type="button" id="indexmsg " value="Start Indexing" onClick="onClickStartIndexingWithGloda()" />
</body>
</html>
The problem is that the call “GlodaMsgIndexer._worker_folderIndex(job);” in function onClickStartIndexingWithGloda () does not really start the indexing. I guess it should be called in some asynchronous manner but I do not know how to start it asynchronously. I would very much appreciate any help here. One more question, would this method work if the folder is already indexed? If not, what is necessary to do to re-index an already indexed folder?