diff --git a/novelwriter/constants.py b/novelwriter/constants.py index dba2d2d0..c06fb4c0 100644 --- a/novelwriter/constants.py +++ b/novelwriter/constants.py @@ -87,8 +87,8 @@ class nwFiles: # Project Meta Files BUILDS_FILE = "builds.json" - INDEX_FILE = "tagsIndex.json" - OPTS_FILE = "guiOptions.json" + INDEX_FILE = "index.json" + OPTS_FILE = "options.json" PROJ_DICT = "wordlist.txt" SESS_STATS = "sessionStats.log" diff --git a/novelwriter/core/storage.py b/novelwriter/core/storage.py index 5fed4fce..7bbc5000 100644 --- a/novelwriter/core/storage.py +++ b/novelwriter/core/storage.py @@ -325,7 +325,7 @@ class NWStorage: self._legacyDataFolder(path, child) # Check for no longer used files, and delete them - self._deleteDeprecatedFiles(path) + self._deprecatedFiles(path) return True @@ -372,9 +372,10 @@ class NWStorage: return - def _deleteDeprecatedFiles(self, path: Path): - """Delete files that are no longer used by novelWriter.""" + def _deprecatedFiles(self, path: Path): + """Handle files that are no longer used by novelWriter.""" remove = [ + path / "meta" / "tagsIndex.json", # Renamed in 2.1 Beta 1 path / "meta" / "mainOptions.json", # Replaced in 0.5 path / "meta" / "exportOptions.json", # Replaced in 0.5 path / "meta" / "outlineOptions.json", # Replaced in 0.5 @@ -395,6 +396,17 @@ class NWStorage: logger.info("Deleted: %s", item) except Exception as 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 # END Class NWStorage diff --git a/tests/test_core/test_core_storage.py b/tests/test_core/test_core_storage.py index c0410964..c8967d63 100644 --- a/tests/test_core/test_core_storage.py +++ b/tests/test_core/test_core_storage.py @@ -286,11 +286,11 @@ def testCoreStorage_PrepareStorage(monkeypatch, fncPath): with monkeypatch.context() as mp: mp.setattr("pathlib.Path.unlink", causeOSError) - storage._deleteDeprecatedFiles(fncPath) + storage._deprecatedFiles(fncPath) for depFile in remove: assert depFile.exists() - storage._deleteDeprecatedFiles(fncPath) + storage._deprecatedFiles(fncPath) for depFile in remove: assert not depFile.exists()