From 16ce55ba60b37e332b670d302ca253cd03a61e2f Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Sun, 20 Mar 2022 15:09:46 +0100 Subject: [PATCH 1/3] Make sure empty files are indexed (#1022) * Make sure also empty files are indexed * Update comments --- novelwriter/core/index.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/novelwriter/core/index.py b/novelwriter/core/index.py index fa4f01dd..b05fa952 100644 --- a/novelwriter/core/index.py +++ b/novelwriter/core/index.py @@ -112,8 +112,7 @@ class NWIndex(): theDoc = NWDoc(self.theProject, tHandle) theText = theDoc.readDocument() - if theText: - self.scanText(tHandle, theText) + self.scanText(tHandle, theText if theText is not None else "") return True @@ -217,18 +216,19 @@ class NWIndex(): if theItem.itemType != nwItemType.FILE: logger.info("Not indexing non-file item '%s'", tHandle) return False + + # Run word counter for the whole text + cC, wC, pC = countWords(theText) + self._fileMeta[tHandle] = ["H0", cC, wC, pC] + + # If the file's meta data is missing, or the file is out of the + # main project, we don't index the content if theItem.itemLayout == nwItemLayout.NO_LAYOUT: logger.info("Not indexing no-layout item '%s'", tHandle) return False if theItem.itemParent is None: logger.info("Not indexing orphaned item '%s'", tHandle) return False - - # Run word counter for the whole text - cC, wC, pC = countWords(theText) - self._fileMeta[tHandle] = ["H0", cC, wC, pC] - - # If the file is archived or in trash, we don't index the content if self.theProject.projTree.isTrashRoot(theItem.itemParent): logger.debug("Not indexing trash item '%s'", tHandle) return False From 8c4e5b99fe1f80077e4ed3691b9b944a753638ea Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Sun, 20 Mar 2022 15:22:09 +0100 Subject: [PATCH 2/3] Only compute shasum of file if it exists (#1023) --- novelwriter/core/document.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/novelwriter/core/document.py b/novelwriter/core/document.py index 71916af8..2334c77c 100644 --- a/novelwriter/core/document.py +++ b/novelwriter/core/document.py @@ -89,9 +89,10 @@ class NWDoc(): theText = "" self._docMeta = {} - self._prevHash = sha256sum(docPath) + self._prevHash = None if os.path.isfile(docPath): + self._prevHash = sha256sum(docPath) try: with open(docPath, mode="r", encoding="utf-8") as inFile: # Check the first <= 10 lines for metadata From 203e353e92a95e3f134ba79299859ded5cf807c5 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Sun, 20 Mar 2022 15:44:52 +0100 Subject: [PATCH 3/3] Release 1.6.2 (#1024) --- CHANGELOG.md | 31 ++++++++++++++++++++--- novelwriter/__init__.py | 6 ++--- novelwriter/assets/text/release_notes.htm | 14 +++++++--- sample/nwProject.nwx | 6 ++--- 4 files changed, 45 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c864ca1..00509e4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,37 @@ # novelWriter Changelog +## Version 1.6.2 [2022-03-20] + +### Release Notes + +This is a bugfix release that fixes a couple of minor issues. Projects containing one or more empty +documents would trigger a rebuild of the index each time the project was opened. This has now been +fixed. Another fix resolves an error message being written to the console logging output when a new +document was created. Both errors were harmless. + +### Detailed Changelog + +**Bugfixes** + +* Fixed an issue where projects containing empty documents would trigger an index rebuild on open, + but the empty document would be skipped due to a check that skips empty documents. As a + consequence, the index would be rebuilt each time the project was opened. Empty documents are now + added to the index, resolving this issue. Issue #1020. PR #1022. +* Fixed an issue where the shasum calculation would be performed when a new document was created, + which would fail as the file did not yet exist. The error was handled, but an error message was + printed to the console log. The shasum is now no longer called if the file doesn't already exist. + Issue #1021. PR #1023. + +---- + ## Version 1.6.1 [2022-03-16] ### Release Notes -This is a bugfix and patch release that fixes two recursion/loop issues. One can cause a crash if -the window is resized rapidly, and one can cause a hang with certain search parameters in the -editor's search box. The Latin American Spanish translation has also been updated. +This is a bugfix and patch release that fixes two recursion/loop issues. One would potentially +cause a crash if the window was resized rapidly, and one would cause a hang with certain search +parameters in the editor's search box. The Latin American Spanish translation has also been +updated. ### Detailed Changelog diff --git a/novelwriter/__init__.py b/novelwriter/__init__.py index 485dc406..0afbf118 100644 --- a/novelwriter/__init__.py +++ b/novelwriter/__init__.py @@ -60,9 +60,9 @@ __license__ = "GPLv3" __author__ = "Veronica Berglyd Olsen" __maintainer__ = "Veronica Berglyd Olsen" __email__ = "code@vkbo.net" -__version__ = "1.6.1" -__hexversion__ = "0x010601f0" -__date__ = "2022-03-16" +__version__ = "1.6.2" +__hexversion__ = "0x010602f0" +__date__ = "2022-03-20" __status__ = "Stable" __domain__ = "novelwriter.io" __url__ = "https://novelwriter.io" diff --git a/novelwriter/assets/text/release_notes.htm b/novelwriter/assets/text/release_notes.htm index 6c4a7d99..0850e30c 100644 --- a/novelwriter/assets/text/release_notes.htm +++ b/novelwriter/assets/text/release_notes.htm @@ -41,9 +41,17 @@ not compatible.

Patch 1.6.1 – 16 March 2022

-

This is a bugfix and patch release that fixes two recursion/loop issues. One can cause a crash -if the window is resized rapidly, and one can cause a hang with certain search parameters in the -editor's search box. The Latin American Spanish translation has also been updated.

+

This is a bugfix and patch release that fixes two recursion/loop issues. One would potentially +cause a crash if the window was resized rapidly, and one would cause a hang with certain search +parameters in the editor's search box. The Latin American Spanish translation has also been +updated.

+ +

Patch 1.6.2 – 20 March 2022

+ +

This is a bugfix release that fixes a couple of minor issues. Projects containing one or more +empty documents would trigger a rebuild of the index each time the project was opened. This has now +been fixed. Another fix resolves an error message being written to the console logging output when +a new document was created. Both errors were harmless.

diff --git a/sample/nwProject.nwx b/sample/nwProject.nwx index 95a4d168..5be5d7af 100644 --- a/sample/nwProject.nwx +++ b/sample/nwProject.nwx @@ -1,13 +1,13 @@ - + Sample Project Sample Project Jane Smith Jay Doh - 1301 + 1302 199 - 64982 + 64999 False