Rename index and options meta files
This commit is contained in:
@@ -87,8 +87,8 @@ class nwFiles:
|
|||||||
|
|
||||||
# Project Meta Files
|
# Project Meta Files
|
||||||
BUILDS_FILE = "builds.json"
|
BUILDS_FILE = "builds.json"
|
||||||
INDEX_FILE = "tagsIndex.json"
|
INDEX_FILE = "index.json"
|
||||||
OPTS_FILE = "guiOptions.json"
|
OPTS_FILE = "options.json"
|
||||||
PROJ_DICT = "wordlist.txt"
|
PROJ_DICT = "wordlist.txt"
|
||||||
SESS_STATS = "sessionStats.log"
|
SESS_STATS = "sessionStats.log"
|
||||||
|
|
||||||
|
|||||||
@@ -325,7 +325,7 @@ class NWStorage:
|
|||||||
self._legacyDataFolder(path, child)
|
self._legacyDataFolder(path, child)
|
||||||
|
|
||||||
# Check for no longer used files, and delete them
|
# Check for no longer used files, and delete them
|
||||||
self._deleteDeprecatedFiles(path)
|
self._deprecatedFiles(path)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -372,9 +372,10 @@ class NWStorage:
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def _deleteDeprecatedFiles(self, path: Path):
|
def _deprecatedFiles(self, path: Path):
|
||||||
"""Delete files that are no longer used by novelWriter."""
|
"""Handle files that are no longer used by novelWriter."""
|
||||||
remove = [
|
remove = [
|
||||||
|
path / "meta" / "tagsIndex.json", # Renamed in 2.1 Beta 1
|
||||||
path / "meta" / "mainOptions.json", # Replaced in 0.5
|
path / "meta" / "mainOptions.json", # Replaced in 0.5
|
||||||
path / "meta" / "exportOptions.json", # Replaced in 0.5
|
path / "meta" / "exportOptions.json", # Replaced in 0.5
|
||||||
path / "meta" / "outlineOptions.json", # Replaced in 0.5
|
path / "meta" / "outlineOptions.json", # Replaced in 0.5
|
||||||
@@ -395,6 +396,17 @@ class NWStorage:
|
|||||||
logger.info("Deleted: %s", item)
|
logger.info("Deleted: %s", item)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
logger.warning("Failed to delete: %s", item, exc_info=exc)
|
logger.warning("Failed to delete: %s", item, exc_info=exc)
|
||||||
|
|
||||||
|
# Renamed in 2.1 Beta 1, but this file we want to keep
|
||||||
|
oldOpt = path / "meta" / "guiOptions.json"
|
||||||
|
newOpt = path / "meta" / nwFiles.OPTS_FILE
|
||||||
|
if oldOpt.is_file():
|
||||||
|
try:
|
||||||
|
oldOpt.rename(newOpt)
|
||||||
|
logger.info("Renamed: %s > %s", oldOpt, newOpt)
|
||||||
|
except Exception as exc:
|
||||||
|
logger.warning("Failed to rename: %s", oldOpt, exc_info=exc)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# END Class NWStorage
|
# END Class NWStorage
|
||||||
|
|||||||
@@ -286,11 +286,11 @@ def testCoreStorage_PrepareStorage(monkeypatch, fncPath):
|
|||||||
|
|
||||||
with monkeypatch.context() as mp:
|
with monkeypatch.context() as mp:
|
||||||
mp.setattr("pathlib.Path.unlink", causeOSError)
|
mp.setattr("pathlib.Path.unlink", causeOSError)
|
||||||
storage._deleteDeprecatedFiles(fncPath)
|
storage._deprecatedFiles(fncPath)
|
||||||
for depFile in remove:
|
for depFile in remove:
|
||||||
assert depFile.exists()
|
assert depFile.exists()
|
||||||
|
|
||||||
storage._deleteDeprecatedFiles(fncPath)
|
storage._deprecatedFiles(fncPath)
|
||||||
for depFile in remove:
|
for depFile in remove:
|
||||||
assert not depFile.exists()
|
assert not depFile.exists()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user