Use the quick read feature wherever we only need document text

This commit is contained in:
Veronica Berglyd Olsen
2024-03-26 11:56:31 +01:00
parent 738f022212
commit 6a7262b817
7 changed files with 22 additions and 58 deletions
+5 -8
View File
@@ -122,9 +122,8 @@ class NWIndex:
self.clearIndex()
for nwItem in self._project.tree:
if nwItem.isFileType():
tHandle = nwItem.itemHandle
doc = self._project.storage.getDocument(tHandle)
self.scanText(tHandle, doc.readDocument() or "", blockSignal=True)
text = self._project.storage.getDocumentText(nwItem.itemHandle)
self.scanText(nwItem.itemHandle, text, blockSignal=True)
self._indexBroken = False
SHARED.indexSignalProxy({"event": "buildIndex"})
return
@@ -142,17 +141,15 @@ class NWIndex:
})
return
def reIndexHandle(self, tHandle: str | None) -> bool:
def reIndexHandle(self, tHandle: str | None) -> None:
"""Put a file back into the index. This is used when files are
moved from the archive or trash folders back into the active
project.
"""
if tHandle and self._project.tree.checkType(tHandle, nwItemType.FILE):
logger.debug("Re-indexing item '%s'", tHandle)
doc = self._project.storage.getDocument(tHandle)
self.scanText(tHandle, doc.readDocument() or "")
return True
return False
self.scanText(tHandle, self._project.storage.getDocumentText(tHandle))
return
def indexChangedSince(self, checkTime: int | float) -> bool:
"""Check if the index has changed since a given time."""