Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if the Realm folder exists before using the lock file. #4855

Merged
merged 11 commits into from
Aug 26, 2021
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,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.

-----------

Expand Down
1 change: 1 addition & 0 deletions src/realm/util/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion test/object-store/realm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
7 changes: 7 additions & 0 deletions test/test_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,13 @@ TEST(File_NotFound)
}


TEST(File_PathNotFound)
{
File file;
CHECK_THROW(file.open(""), File::NotFound);
}


TEST(File_Exists)
{
TEST_PATH(path);
Expand Down