Make some improvements to the tree consistency check

This commit is contained in:
Veronica Berglyd Olsen
2023-07-22 01:06:04 +02:00
parent 3753f5b829
commit d382775d1d
2 changed files with 14 additions and 12 deletions
+10 -7
View File
@@ -195,21 +195,24 @@ class NWTree:
the project returns. The functions requires a prefix string to the project returns. The functions requires a prefix string to
mark recovered files. mark recovered files.
""" """
storage = self._project.storage
files = set(storage.scanContent())
for tHandle in self._treeOrder: for tHandle in self._treeOrder:
if self.updateItemData(tHandle): if self.updateItemData(tHandle):
logger.debug("Checking item '%s' ... OK", tHandle) logger.debug("Checking item '%s' ... OK", tHandle)
files.discard(tHandle) # Remove it from the record
else: else:
logger.error("Checking item '%s' ... ERROR", tHandle) logger.error("Checking item '%s' ... ERROR", tHandle)
self.__delitem__(tHandle) # The file will be re-added as orphaned self.__delitem__(tHandle) # The file will be re-added as orphaned
orphans = 0 orphans = len(files)
recovered = 0 if orphans == 0:
storage = self._project.storage logger.info("Checked project files: OK")
for cHandle in storage.scanContent(): return 0, 0
if cHandle in self._treeOrder:
continue
orphans += 1 logger.warning("Found %d file(s) not tracked in project", orphans)
recovered = 0
for cHandle in files:
aDoc = storage.getDocument(cHandle) aDoc = storage.getDocument(cHandle)
aDoc.readDocument(isOrphan=True) aDoc.readDocument(isOrphan=True)
oName, oParent, oClass, oLayout = aDoc.getMeta() oName, oParent, oClass, oLayout = aDoc.getMeta()
+4 -5
View File
@@ -1046,13 +1046,12 @@ class GuiProjectTree(QTreeWidget):
""" """
logger.debug("Building the project tree ...") logger.debug("Building the project tree ...")
self.clearTree() self.clearTree()
count = 0
iCount = 0
for nwItem in self.theProject.getProjectItems(): for nwItem in self.theProject.getProjectItems():
iCount += 1 count += 1
self._addTreeItem(nwItem) self._addTreeItem(nwItem)
if count > 0:
logger.debug("%d item(s) added to the project tree", iCount) logger.info("%d item(s) added to the project tree", count)
return return
def undoLastMove(self): def undoLastMove(self):