No more document .bak files, .nwd~ works just fine.

This commit is contained in:
Veronica K. B. Olsen
2020-05-27 20:31:09 +02:00
parent 118ffc81e5
commit 03751c5ff9
4 changed files with 26 additions and 24 deletions
+8 -6
View File
@@ -147,12 +147,10 @@ class NWDoc():
mkdir(dataPath)
logger.debug("Created folder %s" % dataPath)
docTemp = path.join(dataPath, docFile+"~")
docBack = path.join(dataPath, docFile[:-3]+"bak")
itemPath = self.theProject.projTree.getItemPath(self.docHandle)
docMeta = "%%~ "+":".join(itemPath)+":"+self.theItem.itemName+"\n"
docTemp = path.join(dataPath, docFile+"~")
try:
with open(docTemp,mode="w",encoding="utf8") as outFile:
outFile.write(docMeta)
@@ -161,12 +159,16 @@ class NWDoc():
self.makeAlert(["Could not save document.",str(e)], nwAlert.ERROR)
return False
# If we're here, the file was successfully saved,
# so let's sort out the temps and backups
# Remove bak files from old file save method, if one exists
# This part can eventually be removed
docBack = path.join(dataPath, docFile[:-3]+"bak")
if path.isfile(docBack):
unlink(docBack)
# If we're here, the file was successfully saved, so we can
# replace the temp file with the actual file
if path.isfile(docPath):
rename(docPath, docBack)
unlink(docPath)
rename(docTemp, docPath)
self.theParent.statusBar.setStatus("Saved Document: %s" % self.theItem.itemName)
+1 -1
View File
@@ -1,4 +1,4 @@
%%~ b8136a5a774a0:98acd8c76c93a:Delete Me!
%%~ b8136a5a774a0:7031beac91f75:Delete Me!
### Delete Me!
This scene is trash.
+1 -1
View File
@@ -1,4 +1,4 @@
%%~ edca4be2fcaf8:7031beac91f75:Part 1
%%~ edca4be2fcaf8:7031beac91f75:Part One
# Part One
The first part.
+16 -16
View File
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<novelWriterXML appVersion="0.6" hexVersion="0x000600f0" fileVersion="1.0" saveCount="168" autoCount="26" timeStamp="2020-05-24 18:33:34">
<novelWriterXML appVersion="0.6.1" hexVersion="0x000601f0" fileVersion="1.0" saveCount="169" autoCount="28" timeStamp="2020-05-27 20:30:19">
<project>
<name>Sample Project</name>
<title>Sample Project</title>
@@ -12,7 +12,7 @@
<autoOutline>True</autoOutline>
<lastEdited>636b6aa9b697b</lastEdited>
<lastViewed>ba8a28a246524</lastViewed>
<lastWordCount>914</lastWordCount>
<lastWordCount>920</lastWordCount>
<autoReplace>
<A>B</A>
<B>E</B>
@@ -73,7 +73,7 @@
<expanded>False</expanded>
<exported>True</exported>
<layout>PAGE</layout>
<charCount>208</charCount>
<charCount>210</charCount>
<wordCount>40</wordCount>
<paraCount>2</paraCount>
<cursorPos>213</cursorPos>
@@ -89,7 +89,7 @@
<charCount>23</charCount>
<wordCount>5</wordCount>
<paraCount>1</paraCount>
<cursorPos>0</cursorPos>
<cursorPos>27</cursorPos>
</item>
<item handle="e7ded148d6e4a" order="3" parent="7031beac91f75">
<name>A Folder</name>
@@ -122,7 +122,7 @@
<charCount>1199</charCount>
<wordCount>216</wordCount>
<paraCount>7</paraCount>
<cursorPos>527</cursorPos>
<cursorPos>825</cursorPos>
</item>
<item handle="bc0cbd2a407f3" order="2" parent="e7ded148d6e4a">
<name>Another Scene</name>
@@ -135,7 +135,7 @@
<charCount>476</charCount>
<wordCount>93</wordCount>
<paraCount>3</paraCount>
<cursorPos>551</cursorPos>
<cursorPos>428</cursorPos>
</item>
<item handle="ba8a28a246524" order="3" parent="e7ded148d6e4a">
<name>Interlude</name>
@@ -148,7 +148,7 @@
<charCount>633</charCount>
<wordCount>101</wordCount>
<paraCount>3</paraCount>
<cursorPos>1238</cursorPos>
<cursorPos>752</cursorPos>
</item>
<item handle="96b68994dfa3d" order="4" parent="e7ded148d6e4a">
<name>A Note on Structure</name>
@@ -161,7 +161,7 @@
<charCount>1692</charCount>
<wordCount>313</wordCount>
<paraCount>6</paraCount>
<cursorPos>1721</cursorPos>
<cursorPos>551</cursorPos>
</item>
<item handle="88706ddc78b1b" order="5" parent="e7ded148d6e4a">
<name>Chapter Two</name>
@@ -174,7 +174,7 @@
<charCount>139</charCount>
<wordCount>28</wordCount>
<paraCount>1</paraCount>
<cursorPos>343</cursorPos>
<cursorPos>242</cursorPos>
</item>
<item handle="ae7339df26ded" order="6" parent="e7ded148d6e4a">
<name>We Found John!</name>
@@ -214,7 +214,7 @@
<charCount>49</charCount>
<wordCount>9</wordCount>
<paraCount>1</paraCount>
<cursorPos>24</cursorPos>
<cursorPos>65</cursorPos>
</item>
<item handle="bb2c23b3c42cc" order="1" parent="f7e2d9f330615">
<name>Jane Smith</name>
@@ -227,7 +227,7 @@
<charCount>55</charCount>
<wordCount>9</wordCount>
<paraCount>1</paraCount>
<cursorPos>25</cursorPos>
<cursorPos>71</cursorPos>
</item>
<item handle="15c4492bd5107" order="2" parent="None">
<name>Locations</name>
@@ -247,7 +247,7 @@
<charCount>76</charCount>
<wordCount>15</wordCount>
<paraCount>1</paraCount>
<cursorPos>20</cursorPos>
<cursorPos>93</cursorPos>
</item>
<item handle="f1471bef9f2ae" order="1" parent="15c4492bd5107">
<name>Space</name>
@@ -260,7 +260,7 @@
<charCount>115</charCount>
<wordCount>24</wordCount>
<paraCount>1</paraCount>
<cursorPos>133</cursorPos>
<cursorPos>135</cursorPos>
</item>
<item handle="5eaea4e8cdee8" order="2" parent="15c4492bd5107">
<name>Mars</name>
@@ -290,9 +290,9 @@
<expanded>False</expanded>
<exported>True</exported>
<layout>SCENE</layout>
<charCount>0</charCount>
<wordCount>0</wordCount>
<paraCount>0</paraCount>
<charCount>30</charCount>
<wordCount>6</wordCount>
<paraCount>1</paraCount>
<cursorPos>36</cursorPos>
</item>
</content>