From 1eb6b59c32e247a4ca9d8b7758fd525e82c9be1b Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Tue, 10 Dec 2019 19:05:57 +0100 Subject: [PATCH] Allow tags in files with no title --- nw/project/index.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nw/project/index.py b/nw/project/index.py index 63f90eab..499d5765 100644 --- a/nw/project/index.py +++ b/nw/project/index.py @@ -233,7 +233,12 @@ class NWIndex(): logger.debug("Indexing item with handle %s" % tHandle) # Check file type, and reset its old index + # Also add an entry for T0 in case the file has no title self.refIndex[tHandle] = {} + self.refIndex[tHandle]["T0"] = { + "tags" : [], + "updated" : time(), + } if itemLayout == nwItemLayout.NOTE: self.noteIndex[tHandle] = {} isNovel = False @@ -375,6 +380,9 @@ class NWIndex(): return False sTitle = "T%d" % nTitle + if sTitle not in self.refIndex[tHandle]: + logger.error("Cannot save tags to file %s, no title %s" % (tHandle, sTitle)) + return False if theBits[0] != nwKeyWords.TAG_KEY: for aVal in theBits[1:]: