Skip to content

Commit

Permalink
Check if the Realm folder exists before using the lock file. (#4855)
Browse files Browse the repository at this point in the history
  • Loading branch information
DominicFrei authored Aug 26, 2021
1 parent fc25035 commit 9b4041b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

-----------

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

0 comments on commit 9b4041b

Please sign in to comment.