-
Notifications
You must be signed in to change notification settings - Fork 173
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
Report if Realm::delete_files() actually deleted the Realm file #4771
Conversation
util::File::try_remove(file_path); // Throws | ||
} | ||
} | ||
void Realm::delete_files(const std::string& realm_file_path, bool* did_delete_realm) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need an out parameter vs just returning true/false? Is it because it'll be less obvious to a caller what the return value signifies?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function can't return a value if it throws an exception, but the obj-c API does return a value even if it reports an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I understand - I guess I didn't think through the PR description, but it does make sense!
8a3f67d
to
f7ee79e
Compare
Our objective-c API for removing files returns true if the Realm file was deleted, and sets an error out parameter if any errors occurred. This means that even if an exception is thrown when trying to delete one of the auxiliary files we still need to know if the main file was deleted, and that awkwardly requires an out parameter. This also refactors things to eliminate the unordered_map of auxiliary files because none of the things using it actually needed a map, and consolidates the two places where we deleted all the files into one.
f7ee79e
to
427affa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code reads nicer with these changes too 👍
Our objective-c API for removing files returns true if the Realm file was deleted, and sets an error out parameter if any errors occurred. This means that even if an exception is thrown when trying to delete one of the auxiliary files we still need to know if the main file was deleted, and that awkwardly requires an out parameter.
This also refactors things to eliminate the unordered_map of auxiliary files because none of the things using it actually needed a map, and consolidates the two places where we deleted all the files into one.