diff --git a/novelwriter/core/storage.py b/novelwriter/core/storage.py index dc670d3f..2740d19d 100644 --- a/novelwriter/core/storage.py +++ b/novelwriter/core/storage.py @@ -183,11 +183,15 @@ class NWStorage: # 2. A full path to an nwProject.nwx file if inPath.is_dir() and inPath != Path.home().resolve(): nwxFile = inPath / nwFiles.PROJ_FILE - elif inPath.is_file() and inPath.name == nwFiles.PROJ_FILE: - nwxFile = inPath + elif inPath.is_file(): + if inPath.name == nwFiles.PROJ_FILE: + nwxFile = inPath + else: + logger.error("Not a novelWriter project") + return NWStorageOpen.UNKOWN else: - logger.error("Not a novelWriter project") - return NWStorageOpen.UNKOWN + logger.error("Not found: %s", inPath) + return NWStorageOpen.NOT_FOUND if not nwxFile.exists(): # The .nwx file must exist to continue diff --git a/tests/test_core/test_core_storage.py b/tests/test_core/test_core_storage.py index 7b6cb5b1..213cf9b3 100644 --- a/tests/test_core/test_core_storage.py +++ b/tests/test_core/test_core_storage.py @@ -111,12 +111,15 @@ def testCoreStorage_InitProjectStorage(mockGUI, fncPath, mockRnd): buildTestProject(project, fncPath) # Init with the wrong file + foo = fncPath / "foobar.txt" + foo.touch() assert storage.initProjectStorage(fncPath / "foobar.txt") == NWStorageOpen.UNKOWN + foo.unlink() storage._clearLockFile() storage.clear() # Init with the user's home dir - assert storage.initProjectStorage(Path.home()) == NWStorageOpen.UNKOWN + assert storage.initProjectStorage(Path.home()) == NWStorageOpen.NOT_FOUND storage._clearLockFile() storage.clear()