diff --git a/CHANGELOG.md b/CHANGELOG.md index c537689cd87..7b0b80a80c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,10 @@ ### Fixed * Fixes prior_size history corruption when replacing an embedded object in a list ([#4845](https://github.com/realm/realm-core/issues/4845)) * Updated the Catch2 URL to include '.git' extension ([#4608](https://github.com/realm/realm-core/issues/4608)) +* Fixes a crash when accessing the lock file during deletion of a Realm on Windows if the folder does not exist. ([#4855](https://github.com/realm/realm-core/pull/4855)) + +### Breaking changes +* None. ----------- diff --git a/src/realm/util/file.cpp b/src/realm/util/file.cpp index f8973dde675..f51cf5d0b4f 100644 --- a/src/realm/util/file.cpp +++ b/src/realm/util/file.cpp @@ -407,6 +407,7 @@ void File::open_internal(const std::string& path, AccessMode a, CreateMode c, in case ERROR_ACCESS_DENIED: throw PermissionDenied(msg, path); case ERROR_FILE_NOT_FOUND: + case ERROR_PATH_NOT_FOUND: throw NotFound(msg, path); case ERROR_FILE_EXISTS: throw Exists(msg, path); diff --git a/test/object-store/realm.cpp b/test/object-store/realm.cpp index d6923afb172..6d63ce45a8d 100644 --- a/test/object-store/realm.cpp +++ b/test/object-store/realm.cpp @@ -1062,7 +1062,9 @@ TEST_CASE("Realm::delete_files()") { SECTION("Calling delete on a folder that does not exist.") { auto fake_path = "/tmp/doesNotExist/realm.424242"; - Realm::delete_files(fake_path); + bool did_delete = false; + Realm::delete_files(fake_path, &did_delete); + REQUIRE_FALSE(did_delete); } SECTION("passing did_delete is optional") { diff --git a/test/test_file.cpp b/test/test_file.cpp index 1add7d2b1d1..80be5327b4a 100644 --- a/test/test_file.cpp +++ b/test/test_file.cpp @@ -392,6 +392,13 @@ TEST(File_NotFound) } +TEST(File_PathNotFound) +{ + File file; + CHECK_THROW(file.open(""), File::NotFound); +} + + TEST(File_Exists) { TEST_PATH(path);