Added some checks for corrupt novel project files
This commit is contained in:
@@ -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
@@ -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
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user