Commit ba29fd0d authored by Mohamed Amir Yosef's avatar Mohamed Amir Yosef Committed by Commit Bot

[Sync:USS] DCHECK bookmarks have valid unique_position in directory

uss_migrator is responsible for migration (meta)data from the directory
to the USS architecture upon first time switching to USS.
USS assumes that all bookmarks have valid unique_position.
This CL adds a DCHECK that this is actually the case.
Directory is responsible for assigning valid unique positions for
legacy bookmarks that are missing the field.

Bug: 516866
Change-Id: Ib963016a56c4c9275649a1ff78f440d7fbe23023
Reviewed-on: https://chromium-review.googlesource.com/1240296
Commit-Queue: Mohamed Amir Yosef <mamir@chromium.org>
Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#593548}
parent 95efafd4
......@@ -23,7 +23,8 @@ namespace syncer {
namespace {
bool ExtractSyncEntity(ReadTransaction* trans,
bool ExtractSyncEntity(ModelType type,
ReadTransaction* trans,
int64_t id,
sync_pb::SyncEntity* entity) {
ReadNode read_node(trans);
......@@ -50,6 +51,11 @@ bool ExtractSyncEntity(ReadTransaction* trans,
if (entry.GetServerUniquePosition().IsValid()) {
*entity->mutable_unique_position() =
entry.GetServerUniquePosition().ToProto();
} else {
// All boookmarks should have valid unique_positions including legacy
// bookmarks that are missing the field. Directory should have taken care of
// assigning proper unique_position during the first sync flow.
DCHECK_NE(BOOKMARKS, type);
}
entity->set_server_defined_unique_tag(entry.GetUniqueServerTag());
......@@ -103,7 +109,7 @@ bool MigrateDirectoryDataWithBatchSize(ModelType type,
const size_t batch_limit = std::min(i + batch_size, child_ids.size());
for (; i < batch_limit; i++) {
auto entity = std::make_unique<sync_pb::SyncEntity>();
if (!ExtractSyncEntity(&trans, child_ids[i], entity.get())) {
if (!ExtractSyncEntity(type, &trans, child_ids[i], entity.get())) {
LOG(ERROR) << "Failed to fetch child node for "
<< ModelTypeToString(type);
// Inform the worker so it can clear any partial data and trigger a
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment