Indexer should still count words for trash and archived files

This commit is contained in:
Veronica K. B. Olsen
2020-08-16 18:39:34 +02:00
parent 5fb0b9cfb1
commit e4ad4f38c8
+10 -7
View File
@@ -268,21 +268,28 @@ class NWIndex():
"""
theItem = self.theProject.projTree[tHandle]
theRoot = self.theProject.projTree.getRootItem(tHandle)
if theItem is None:
logger.error("Not indexing unknown item %s" % tHandle)
return False
if theItem.itemType != nwItemType.FILE:
logger.error("Not indexing non-file item %s" % tHandle)
return False
if theItem.parHandle == self.theProject.projTree.trashRoot():
logger.error("Not indexing trash item %s" % tHandle)
return False
if theItem.itemLayout == nwItemLayout.NO_LAYOUT:
logger.error("Not indexing no-layout item %s" % tHandle)
return False
if theRoot is None:
logger.error("Not indexing homeless item %s" % tHandle)
return False
# Run word counter for whole text
cC, wC, pC = countWords(theText)
self.textCounts[tHandle] = [cC, wC, pC]
# If the file is archived or trashed, we don't index the file itself
if theItem.parHandle == self.theProject.projTree.trashRoot():
logger.error("Not indexing trash item %s" % tHandle)
return False
if theRoot.itemClass == nwItemClass.ARCHIVE:
logger.error("Not indexing archived item %s" % tHandle)
return False
@@ -351,10 +358,6 @@ class NWIndex():
lastText = "\n".join(theLines[nTitle-1:nLine-1])
self._indexWordCounts(tHandle, isNovel, lastText, nTitle)
# Run word counter for whole text
cC, wC, pC = countWords(theText)
self.textCounts[tHandle] = [cC, wC, pC]
# Update timestamps for index changes
nowTime = time()
self.timeIndex = nowTime