realm-swift
realm-swift copied to clipboard
Fix calling schemaVersionForRealmAtURL() on read-only Realms
This is the issue that #3528 was attempting to fix, but the patch was incomplete. Here's one potential solution:
Unconditionally opening it in readOnly mode could result in incorrect results and/or crashes if the file is being modified by another process at the same time (or another thread, but that at least is solvable and would require doing very weird things anyway), so I think it needs to be a parameter. Maybe it should just take an RLMRealmConfiguration? Presumably if you're calling this method you're going to be creating a config object anyway, but half of the config properties aren't applicable.
Another would be to see if the Realm is already open at that path and to use the same setting, otherwise default to read_only.