Closed kraenhansen closed 4 years ago
It could also report the format number of the file. It should not crash but report an error (which requires those calling open to handle the error)
➤ Jørgen Edelbo commented:
[~kraen.hansen] would you care to verify that the fix is sufficient?
➤ Kræn Hansen commented:
Looking at [the changes on GitHub|https://github.com/realm/realm-core/commit/44f79774acd388f6044ed57a59c01707492b8df0 ( https://github.com/realm/realm-core/commit/44f79774acd388f6044ed57a59c01707492b8df0 )] I believe the chances to the message ("Realm file needs upgrade before opening in RO mode") is sufficient. I'll close when this has released and I've verified it via Realm JS.
➤ Kræn Hansen commented:
Now Realm JS (4.0.0-beta.1) throws an error with the message: "The Realm file format must be allowed to be upgraded in order to proceed."
I thinks it's because the original error gets catched by object store and another error is thrown here https://github.com/realm/realm-object-store/blob/2a204063e1e1a366efbdd909fbea9effceb7d3c4/src/shared_realm.cpp#L138-L143 ( https://github.com/realm/realm-object-store/blob/2a204063e1e1a366efbdd909fbea9effceb7d3c4/src/shared_realm.cpp#L138-L143 ).
That message doesn't point to the fact that it was opened as read-only, but I think its fine in regards to the intention behind this issue.
When opening an old Realm-file with a newer version of Realm Core it automatically upgrades the file to the newest version of the file format. If the user opens the file in read-only mode (via Realm JS), the following error is thrown:
It is not obvious from the message nor stacktrace that the cause of this is the user opening the file in read-only mode. Instead I propose that if an upgrade is needed and the file was opened as read-only, an error with the following message is thrown: