mirror of
https://github.com/status-im/realm-js.git
synced 2025-01-30 16:25:27 +00:00
add hook for detecting file format upgrade
This commit is contained in:
parent
28a7efcd1b
commit
87c9dda321
@ -246,7 +246,6 @@
|
||||
children = (
|
||||
F6BCCFDF1C83809A00FE31AE /* lib */,
|
||||
F62A35131C18E6E2004A917D /* iOS */,
|
||||
F60103051CC4ADE500EC01BA /* JS */,
|
||||
F6874A441CAD2ACD00EEEE36 /* JSC */,
|
||||
F62BF9001CAC72C40022BCDC /* Node */,
|
||||
F62A35141C18E783004A917D /* Object Store */,
|
||||
@ -322,13 +321,6 @@
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F60103051CC4ADE500EC01BA /* JS */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
);
|
||||
name = JS;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F62A35131C18E6E2004A917D /* iOS */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
|
@ -337,6 +337,13 @@ void Realm<T>::constructor(ContextType ctx, ObjectType this_object, size_t argc,
|
||||
ensure_directory_exists_for_file(config.path);
|
||||
|
||||
SharedRealm realm = realm::Realm::get_shared_realm(config);
|
||||
|
||||
// Fix for datetime -> timestamp conversion
|
||||
if (realm->config().upgrade_initial_version != realm->config().upgrade_final_version &&
|
||||
realm->config().upgrade_initial_version < 5) {
|
||||
assert(0);
|
||||
}
|
||||
|
||||
auto delegate = new RealmDelegate<T>(realm, Context<T>::get_global_context(ctx));
|
||||
delegate->m_defaults = std::move(defaults);
|
||||
delegate->m_constructors = std::move(constructors);
|
||||
|
@ -43,13 +43,15 @@ Realm::Config::Config(const Config& c)
|
||||
, cache(c.cache)
|
||||
, disable_format_upgrade(c.disable_format_upgrade)
|
||||
, automatic_change_notifications(c.automatic_change_notifications)
|
||||
, upgrade_final_version(0)
|
||||
, upgrade_initial_version(0)
|
||||
{
|
||||
if (c.schema) {
|
||||
schema = std::make_unique<Schema>(*c.schema);
|
||||
}
|
||||
}
|
||||
|
||||
Realm::Config::Config() : schema_version(ObjectStore::NotVersioned) { }
|
||||
Realm::Config::Config() : schema_version(ObjectStore::NotVersioned), upgrade_initial_version(0), upgrade_final_version(0) { }
|
||||
Realm::Config::Config(Config&&) = default;
|
||||
Realm::Config::~Config() = default;
|
||||
|
||||
@ -71,7 +73,7 @@ Realm::Realm(Config config)
|
||||
}
|
||||
}
|
||||
|
||||
void Realm::open_with_config(const Config& config,
|
||||
void Realm::open_with_config(Config& config,
|
||||
std::unique_ptr<Replication>& history,
|
||||
std::unique_ptr<SharedGroup>& shared_group,
|
||||
std::unique_ptr<Group>& read_only_group)
|
||||
@ -85,9 +87,12 @@ void Realm::open_with_config(const Config& config,
|
||||
throw InvalidEncryptionKeyException();
|
||||
}
|
||||
history = realm::make_client_history(config.path, config.encryption_key.data());
|
||||
SharedGroup::DurabilityLevel durability = config.in_memory ? SharedGroup::durability_MemOnly :
|
||||
SharedGroup::durability_Full;
|
||||
shared_group = std::make_unique<SharedGroup>(*history, durability, config.encryption_key.data(), !config.disable_format_upgrade);
|
||||
SharedGroup::DurabilityLevel durability = config.in_memory ? SharedGroup::durability_MemOnly : SharedGroup::durability_Full;
|
||||
shared_group = std::make_unique<SharedGroup>(*history, durability, config.encryption_key.data(), !config.disable_format_upgrade,
|
||||
[&](int from_version, int to_version) {
|
||||
config.upgrade_initial_version = from_version;
|
||||
config.upgrade_final_version = to_version;
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (util::File::PermissionDenied const& ex) {
|
||||
|
@ -82,7 +82,10 @@ namespace realm {
|
||||
// everything can be done deterministically on one thread, and
|
||||
// speeds up tests that don't need notifications.
|
||||
bool automatic_change_notifications = true;
|
||||
|
||||
// File format versions populated when a file format updrade takes place
|
||||
// during realm opening
|
||||
int upgrade_initial_version, upgrade_final_version;
|
||||
|
||||
Config();
|
||||
Config(Config&&);
|
||||
Config(const Config& c);
|
||||
@ -156,7 +159,7 @@ namespace realm {
|
||||
static _impl::RealmCoordinator& get_coordinator(Realm& realm) { return *realm.m_coordinator; }
|
||||
};
|
||||
|
||||
static void open_with_config(const Config& config,
|
||||
static void open_with_config(Config& config,
|
||||
std::unique_ptr<Replication>& history,
|
||||
std::unique_ptr<SharedGroup>& shared_group,
|
||||
std::unique_ptr<Group>& read_only_group);
|
||||
|
Loading…
x
Reference in New Issue
Block a user