| Index: sync/syncable/mutable_entry.cc
|
| diff --git a/sync/syncable/mutable_entry.cc b/sync/syncable/mutable_entry.cc
|
| index 64a23ced691f04c7f20b9dd1ae1a0504ebc2e878..23531287a764df3eb09e5d22d648b10864543543 100644
|
| --- a/sync/syncable/mutable_entry.cc
|
| +++ b/sync/syncable/mutable_entry.cc
|
| @@ -19,15 +19,9 @@ using std::string;
|
| namespace syncer {
|
| namespace syncable {
|
|
|
| -MutableEntry::MutableEntry(WriteTransaction* trans, Create,
|
| - const Id& parent_id, const string& name)
|
| - : Entry(trans),
|
| - write_transaction_(trans) {
|
| - Init(trans, parent_id, name);
|
| -}
|
| -
|
| -
|
| -void MutableEntry::Init(WriteTransaction* trans, const Id& parent_id,
|
| +void MutableEntry::Init(WriteTransaction* trans,
|
| + ModelType model_type,
|
| + const Id& parent_id,
|
| const string& name) {
|
| scoped_ptr<EntryKernel> kernel(new EntryKernel);
|
| kernel_ = NULL;
|
| @@ -43,9 +37,15 @@ void MutableEntry::Init(WriteTransaction* trans, const Id& parent_id,
|
| // We match the database defaults here
|
| kernel->put(BASE_VERSION, CHANGES_VERSION);
|
| kernel->put(SERVER_ORDINAL_IN_PARENT, NodeOrdinal::CreateInitialOrdinal());
|
| - if (!trans->directory()->InsertEntry(trans, kernel.get())) {
|
| - return; // We failed inserting, nothing more to do.
|
| - }
|
| +
|
| + // Normally the SPECIFICS setting code is wrapped in logic to deal with
|
| + // unknown fields and encryption. Since all we want to do here is ensure that
|
| + // GetModelType() returns a correct value from the very beginning, these
|
| + // few lines are sufficient.
|
| + sync_pb::EntitySpecifics specifics;
|
| + AddDefaultFieldValue(model_type, &specifics);
|
| + kernel->put(SPECIFICS, specifics);
|
| +
|
| // Because this entry is new, it was originally deleted.
|
| kernel->put(IS_DEL, true);
|
| trans->SaveOriginal(kernel.get());
|
| @@ -55,6 +55,18 @@ void MutableEntry::Init(WriteTransaction* trans, const Id& parent_id,
|
| kernel_ = kernel.release();
|
| }
|
|
|
| +MutableEntry::MutableEntry(WriteTransaction* trans,
|
| + Create,
|
| + ModelType model_type,
|
| + const Id& parent_id,
|
| + const string& name)
|
| + : Entry(trans),
|
| + write_transaction_(trans) {
|
| + Init(trans, model_type, parent_id, name);
|
| + bool insert_result = trans->directory()->InsertEntry(trans, kernel_);
|
| + DCHECK(insert_result);
|
| +}
|
| +
|
| MutableEntry::MutableEntry(WriteTransaction* trans, CreateNewUpdateItem,
|
| const Id& id)
|
| : Entry(trans), write_transaction_(trans) {
|
|
|