v1 -> v2 upgrade path
This commit is contained in:
parent
616f5d79e6
commit
183f051bb1
|
@ -4,7 +4,7 @@
|
||||||
* Updating core, sync, object store.
|
* Updating core, sync, object store.
|
||||||
|
|
||||||
### Enhancements
|
### Enhancements
|
||||||
* None
|
* Throw exception with recovery configuration for V1 to V2 upgrade.
|
||||||
|
|
||||||
### Bug fixes
|
### Bug fixes
|
||||||
* None
|
* None
|
||||||
|
|
|
@ -253,6 +253,21 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static void translateSharedGroupOpenException(ContextType ctx, realm::Realm::Config& originalConfiguration) {
|
||||||
|
try {
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
catch (RealmFileException const& ex) {
|
||||||
|
switch (ex.kind()) {
|
||||||
|
case RealmFileException::Kind::IncompatibleSyncedRealm: {
|
||||||
|
throw IncompatibleSyncedRealmException<T>(ctx, ex.path(), originalConfiguration.encryption_key);
|
||||||
|
default:
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static std::string validated_notification_name(ContextType ctx, const ValueType &value) {
|
static std::string validated_notification_name(ContextType ctx, const ValueType &value) {
|
||||||
std::string name = Value::validated_to_string(ctx, value, "notification name");
|
std::string name = Value::validated_to_string(ctx, value, "notification name");
|
||||||
if (name != "change") {
|
if (name != "change") {
|
||||||
|
@ -483,7 +498,13 @@ SharedRealm RealmClass<T>::create_shared_realm(ContextType ctx, realm::Realm::Co
|
||||||
ObjectDefaultsMap && defaults, ConstructorMap && constructors) {
|
ObjectDefaultsMap && defaults, ConstructorMap && constructors) {
|
||||||
config.execution_context = Context<T>::get_execution_context_id(ctx);
|
config.execution_context = Context<T>::get_execution_context_id(ctx);
|
||||||
|
|
||||||
SharedRealm realm = realm::Realm::get_shared_realm(config);
|
SharedRealm realm;
|
||||||
|
try {
|
||||||
|
realm = realm::Realm::get_shared_realm(config);
|
||||||
|
}
|
||||||
|
catch (...) {
|
||||||
|
translateSharedGroupOpenException(ctx, config);
|
||||||
|
}
|
||||||
|
|
||||||
GlobalContextType global_context = Context<T>::get_global_context(ctx);
|
GlobalContextType global_context = Context<T>::get_global_context(ctx);
|
||||||
if (!realm->m_binding_context) {
|
if (!realm->m_binding_context) {
|
||||||
|
@ -693,7 +714,14 @@ void RealmClass<T>::wait_for_download_completion(ContextType ctx, FunctionType,
|
||||||
|
|
||||||
std::function<ProgressHandler> progressFunc;
|
std::function<ProgressHandler> progressFunc;
|
||||||
|
|
||||||
auto realm = realm::Realm::get_shared_realm(config);
|
SharedRealm realm;
|
||||||
|
try {
|
||||||
|
realm = realm::Realm::get_shared_realm(config);
|
||||||
|
}
|
||||||
|
catch (...) {
|
||||||
|
translateSharedGroupOpenException(ctx, config);
|
||||||
|
}
|
||||||
|
|
||||||
if (auto sync_config = config.sync_config)
|
if (auto sync_config = config.sync_config)
|
||||||
{
|
{
|
||||||
static const String progressFuncName = "_onDownloadProgress";
|
static const String progressFuncName = "_onDownloadProgress";
|
||||||
|
|
|
@ -318,6 +318,31 @@ struct Exception : public std::runtime_error {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct IncompatibleSyncedRealmException : public std::runtime_error {
|
||||||
|
using ContextType = typename T::Context;
|
||||||
|
using ObjectType = typename T::Object;
|
||||||
|
|
||||||
|
std::string m_path;
|
||||||
|
std::vector<char> m_encryption_key;
|
||||||
|
|
||||||
|
IncompatibleSyncedRealmException(ContextType ctx, const std::string &path)
|
||||||
|
: std::runtime_error(std::string("Incompatible Synced Realm")), m_path(path) {}
|
||||||
|
IncompatibleSyncedRealmException(ContextType ctx, const std::string &path, const std::vector<char> &key)
|
||||||
|
: std::runtime_error(std::string("Incompatible Synced Realm")), m_path(path), m_encryption_key(key) {}
|
||||||
|
|
||||||
|
|
||||||
|
ObjectType config(ContextType ctx) {
|
||||||
|
ObjectType configuration = ObjectType::create_empty(ctx);
|
||||||
|
ObjectType::set_property(ctx, configuration, "path", m_path);
|
||||||
|
ObjectType::set_property(ctx, configuration, "schema_mode", to_string(ctx, "readOnly"));
|
||||||
|
if (!m_encryption_key.empty()) {
|
||||||
|
ObjectType::set_property(ctx, configuration, "encryption_key", to_binary(ctx, m_encryption_key));
|
||||||
|
}
|
||||||
|
return configuration;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct ReturnValue {
|
struct ReturnValue {
|
||||||
using ValueType = typename T::Value;
|
using ValueType = typename T::Value;
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit d1a101fda6999e070c1e73cc5aff002c3de7c129
|
Subproject commit 317dc9b3d9ef1b5de5ace72e05ac6d58e443bef5
|
Loading…
Reference in New Issue