@@ -270,7 +270,7 @@ void ClientHistory::get_status(version_type& current_client_version, SaltedFileI
270270}
271271
272272
273- void ClientHistory::set_client_file_ident (SaltedFileIdent client_file_ident, bool fix_up_object_ids )
273+ void ClientHistory::set_client_file_ident (SaltedFileIdent client_file_ident)
274274{
275275 REALM_ASSERT (client_file_ident.ident != 0 );
276276
@@ -287,10 +287,6 @@ void ClientHistory::set_client_file_ident(SaltedFileIdent client_file_ident, boo
287287 root.set (s_progress_download_client_version_iip, RefOrTagged::make_tagged (0 ));
288288 root.set (s_progress_upload_client_version_iip, RefOrTagged::make_tagged (0 ));
289289
290- if (fix_up_object_ids) {
291- fix_up_client_file_ident_in_stored_changesets (*wt, client_file_ident.ident ); // Throws
292- }
293-
294290 // Note: This transaction produces an empty changeset. Empty changesets are
295291 // not uploaded to the server.
296292 wt->commit (); // Throws
@@ -1024,98 +1020,6 @@ void ClientHistory::do_trim_sync_history(std::size_t n)
10241020 }
10251021}
10261022
1027- void ClientHistory::fix_up_client_file_ident_in_stored_changesets (Transaction& group,
1028- file_ident_type client_file_ident)
1029- {
1030- // Must be in write transaction!
1031-
1032- REALM_ASSERT (client_file_ident != 0 );
1033- auto promote_global_key = [client_file_ident](GlobalKey* oid) {
1034- if (oid->hi () == 0 ) {
1035- // client_file_ident == 0
1036- *oid = GlobalKey{uint64_t (client_file_ident), oid->lo ()};
1037- return true ;
1038- }
1039- return false ;
1040- };
1041-
1042- Group::TableNameBuffer buffer;
1043- auto get_table_for_class = [&](StringData class_name) -> ConstTableRef {
1044- REALM_ASSERT (class_name.size () < Group::max_table_name_length - 6 );
1045- return group.get_table (Group::class_name_to_table_name (class_name, buffer));
1046- };
1047-
1048- util::compression::CompressMemoryArena arena;
1049- util::AppendBuffer<char > compressed;
1050-
1051- // Fix up changesets.
1052- Array& root = m_arrays->root ;
1053- uint64_t uploadable_bytes = root.get_as_ref_or_tagged (s_progress_uploadable_bytes_iip).get_as_int ();
1054- for (size_t i = 0 ; i < sync_history_size (); ++i) {
1055- // We could have opened a pre-provisioned realm file. In this case we can skip the entries downloaded
1056- // from the server.
1057- if (m_arrays->origin_file_idents .get (i) != 0 )
1058- continue ;
1059-
1060- ChunkedBinaryData changeset{m_arrays->changesets , i};
1061- ChunkedBinaryInputStream is{changeset};
1062- size_t decompressed_size;
1063- auto decompressed = util::compression::decompress_nonportable_input_stream (is, decompressed_size);
1064- if (!decompressed)
1065- continue ;
1066- Changeset log;
1067- parse_changeset (*decompressed, log);
1068-
1069- bool did_modify = false ;
1070- auto last_class_name = InternString::npos;
1071- ConstTableRef selected_table;
1072- for (auto instr : log) {
1073- if (!instr)
1074- continue ;
1075-
1076- if (auto obj_instr = instr->get_if <Instruction::ObjectInstruction>()) {
1077- // Cache the TableRef
1078- if (obj_instr->table != last_class_name) {
1079- StringData class_name = log.get_string (obj_instr->table );
1080- last_class_name = obj_instr->table ;
1081- selected_table = get_table_for_class (class_name);
1082- }
1083-
1084- // Fix up instructions using GlobalKey to identify objects.
1085- if (auto global_key = mpark::get_if<GlobalKey>(&obj_instr->object )) {
1086- did_modify = promote_global_key (global_key);
1087- }
1088-
1089- // Fix up the payload for Set and ArrayInsert.
1090- Instruction::Payload* payload = nullptr ;
1091- if (auto set_instr = instr->get_if <Instruction::Update>()) {
1092- payload = &set_instr->value ;
1093- }
1094- else if (auto list_insert_instr = instr->get_if <Instruction::ArrayInsert>()) {
1095- payload = &list_insert_instr->value ;
1096- }
1097-
1098- if (payload && payload->type == Instruction::Payload::Type::Link) {
1099- if (auto global_key = mpark::get_if<GlobalKey>(&payload->data .link .target )) {
1100- did_modify = promote_global_key (global_key);
1101- }
1102- }
1103- }
1104- }
1105-
1106- if (did_modify) {
1107- ChangesetEncoder::Buffer modified;
1108- encode_changeset (log, modified);
1109- util::compression::allocate_and_compress_nonportable (arena, modified, compressed);
1110- m_arrays->changesets .set (i, BinaryData{compressed.data (), compressed.size ()}); // Throws
1111-
1112- uploadable_bytes += modified.size () - decompressed_size;
1113- }
1114- }
1115-
1116- root.set (s_progress_uploadable_bytes_iip, RefOrTagged::make_tagged (uploadable_bytes));
1117- }
1118-
11191023void ClientHistory::set_group (Group* group, bool updated)
11201024{
11211025 _impl::History::set_group (group, updated);
0 commit comments