Added some checks for corrupt novel project files

This commit is contained in:
Veronica K. B. Olsen
2019-11-02 12:49:13 +01:00
parent 4252df9682
commit dd97aefd60
3 changed files with 12 additions and 6 deletions
+1
View File
@@ -22,6 +22,7 @@ class nwFiles():
APP_ICON = "novelWriter.svg"
PROJ_FILE = "nwProject.nwx"
PROJ_COUNT = "projCount.txt"
PROJ_DICT = "wordlist.txt"
SESS_INFO = "sessionInfo.log"
INDEX_FILE = "tagsIndex.json"
+1 -1
View File
@@ -611,7 +611,7 @@ class GuiMain(QMainWindow):
"""
if isinstance(theMessage, list):
popMsg = "<br>".join(theMessage)
popMsg = " ".join(theMessage)
logMsg = theMessage
else:
popMsg = theMessage
+10 -5
View File
@@ -197,10 +197,15 @@ class NWProject():
if not self._checkFolder(self.projMeta): return
if not self._checkFolder(self.projCache): return
nwXML = etree.parse(fileName)
xRoot = nwXML.getroot()
try:
nwXML = etree.parse(fileName)
except Exception as e:
self.makeAlert(["Failed to parse project xml.",str(e)], nwAlert.ERROR)
return False
xRoot = nwXML.getroot()
nwxRoot = xRoot.tag
nwxRoot = xRoot.tag
appVersion = xRoot.attrib["appVersion"]
fileVersion = xRoot.attrib["fileVersion"]
@@ -709,7 +714,7 @@ class NWProject():
file gets corrupted.
"""
countFile = path.join(self.projCache, "projCount.txt")
countFile = path.join(self.projCache, nwFiles.PROJ_COUNT)
projCount = 0
if path.isfile(countFile):
@@ -718,7 +723,7 @@ class NWProject():
projCount = int(inFile.read())+1
except:
projCount = 0
if projCount > 9:
projCount = 0