From 7373f9636b56d411c22ca04abf65977661076a3c Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Thu, 28 May 2020 19:03:59 +0200 Subject: [PATCH] Updated orphan file check --- nw/core/project.py | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/nw/core/project.py b/nw/core/project.py index fbf04177..96e22103 100644 --- a/nw/core/project.py +++ b/nw/core/project.py @@ -976,29 +976,20 @@ class NWProject(): if self.projPath is None: return - # First, scan the project data folders - itemList = [] - for subItem in listdir(self.projPath): - if subItem[:5] != "data_": - continue - dataDir = path.join(self.projPath,subItem) - for subFile in listdir(dataDir): - if subFile[-4:] == ".nwd": - newItem = path.join(subItem,subFile) - itemList.append(newItem) - - # Then check the valid files + # Then check the files in the data folder orphanFiles = [] - for fileItem in itemList: - if len(fileItem) != 28: - # Just to be safe, shouldn't happen + for fileItem in listdir(self.projData): + if not fileItem.endswith(".nwd"): logger.warning("Skipping file %s" % fileItem) continue - fHandle = fileItem[5]+fileItem[7:19] + if len(fileItem) != 17: + logger.warning("Skipping file %s" % fileItem) + continue + fHandle = fileItem[:13] if fHandle in self.projTree: - logger.debug("Checking file %s, handle %s: OK" % (fileItem,fHandle)) + logger.debug("Checking file %s, handle %s: OK" % (fileItem, fHandle)) else: - logger.debug("Checking file %s, handle %s: Orphaned" % (fileItem,fHandle)) + logger.debug("Checking file %s, handle %s: Orphaned" % (fileItem, fHandle)) orphanFiles.append(fHandle) # Report status