mirror of
https://github.com/status-im/realm-js.git
synced 2025-01-12 23:34:57 +00:00
add hook for detecting file format upgrade
This commit is contained in:
parent
7b3fa3bc42
commit
477f7b1f33
@ -43,13 +43,15 @@ Realm::Config::Config(const Config& c)
|
|||||||
, cache(c.cache)
|
, cache(c.cache)
|
||||||
, disable_format_upgrade(c.disable_format_upgrade)
|
, disable_format_upgrade(c.disable_format_upgrade)
|
||||||
, automatic_change_notifications(c.automatic_change_notifications)
|
, automatic_change_notifications(c.automatic_change_notifications)
|
||||||
|
, upgrade_final_version(0)
|
||||||
|
, upgrade_initial_version(0)
|
||||||
{
|
{
|
||||||
if (c.schema) {
|
if (c.schema) {
|
||||||
schema = std::make_unique<Schema>(*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(Config&&) = default;
|
||||||
Realm::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<Replication>& history,
|
||||||
std::unique_ptr<SharedGroup>& shared_group,
|
std::unique_ptr<SharedGroup>& shared_group,
|
||||||
std::unique_ptr<Group>& read_only_group)
|
std::unique_ptr<Group>& read_only_group)
|
||||||
@ -85,9 +87,12 @@ void Realm::open_with_config(const Config& config,
|
|||||||
throw InvalidEncryptionKeyException();
|
throw InvalidEncryptionKeyException();
|
||||||
}
|
}
|
||||||
history = realm::make_client_history(config.path, config.encryption_key.data());
|
history = realm::make_client_history(config.path, config.encryption_key.data());
|
||||||
SharedGroup::DurabilityLevel durability = config.in_memory ? SharedGroup::durability_MemOnly :
|
SharedGroup::DurabilityLevel durability = config.in_memory ? SharedGroup::durability_MemOnly : SharedGroup::durability_Full;
|
||||||
SharedGroup::durability_Full;
|
shared_group = std::make_unique<SharedGroup>(*history, durability, config.encryption_key.data(), !config.disable_format_upgrade,
|
||||||
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) {
|
catch (util::File::PermissionDenied const& ex) {
|
||||||
|
@ -82,6 +82,9 @@ namespace realm {
|
|||||||
// everything can be done deterministically on one thread, and
|
// everything can be done deterministically on one thread, and
|
||||||
// speeds up tests that don't need notifications.
|
// speeds up tests that don't need notifications.
|
||||||
bool automatic_change_notifications = true;
|
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&&);
|
Config(Config&&);
|
||||||
@ -156,7 +159,7 @@ namespace realm {
|
|||||||
static _impl::RealmCoordinator& get_coordinator(Realm& realm) { return *realm.m_coordinator; }
|
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<Replication>& history,
|
||||||
std::unique_ptr<SharedGroup>& shared_group,
|
std::unique_ptr<SharedGroup>& shared_group,
|
||||||
std::unique_ptr<Group>& read_only_group);
|
std::unique_ptr<Group>& read_only_group);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user