Indexer should still count words for trash and archived files
This commit is contained in:
+10
-7
@@ -268,21 +268,28 @@ class NWIndex():
|
|||||||
"""
|
"""
|
||||||
theItem = self.theProject.projTree[tHandle]
|
theItem = self.theProject.projTree[tHandle]
|
||||||
theRoot = self.theProject.projTree.getRootItem(tHandle)
|
theRoot = self.theProject.projTree.getRootItem(tHandle)
|
||||||
|
|
||||||
if theItem is None:
|
if theItem is None:
|
||||||
logger.error("Not indexing unknown item %s" % tHandle)
|
logger.error("Not indexing unknown item %s" % tHandle)
|
||||||
return False
|
return False
|
||||||
if theItem.itemType != nwItemType.FILE:
|
if theItem.itemType != nwItemType.FILE:
|
||||||
logger.error("Not indexing non-file item %s" % tHandle)
|
logger.error("Not indexing non-file item %s" % tHandle)
|
||||||
return False
|
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:
|
if theItem.itemLayout == nwItemLayout.NO_LAYOUT:
|
||||||
logger.error("Not indexing no-layout item %s" % tHandle)
|
logger.error("Not indexing no-layout item %s" % tHandle)
|
||||||
return False
|
return False
|
||||||
if theRoot is None:
|
if theRoot is None:
|
||||||
logger.error("Not indexing homeless item %s" % tHandle)
|
logger.error("Not indexing homeless item %s" % tHandle)
|
||||||
return False
|
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:
|
if theRoot.itemClass == nwItemClass.ARCHIVE:
|
||||||
logger.error("Not indexing archived item %s" % tHandle)
|
logger.error("Not indexing archived item %s" % tHandle)
|
||||||
return False
|
return False
|
||||||
@@ -351,10 +358,6 @@ class NWIndex():
|
|||||||
lastText = "\n".join(theLines[nTitle-1:nLine-1])
|
lastText = "\n".join(theLines[nTitle-1:nLine-1])
|
||||||
self._indexWordCounts(tHandle, isNovel, lastText, nTitle)
|
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
|
# Update timestamps for index changes
|
||||||
nowTime = time()
|
nowTime = time()
|
||||||
self.timeIndex = nowTime
|
self.timeIndex = nowTime
|
||||||
|
|||||||
Reference in New Issue
Block a user