Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "sync/engine/process_commit_response_command.h" | 5 #include "sync/engine/process_commit_response_command.h" |
| 6 | 6 |
| 7 #include <cstddef> | 7 #include <cstddef> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/location.h" | 13 #include "base/location.h" |
| 14 #include "sync/engine/syncer_proto_util.h" | 14 #include "sync/engine/syncer_proto_util.h" |
| 15 #include "sync/engine/syncer_util.h" | 15 #include "sync/engine/syncer_util.h" |
| 16 #include "sync/engine/syncproto.h" | |
| 17 #include "sync/sessions/sync_session.h" | 16 #include "sync/sessions/sync_session.h" |
| 18 #include "sync/syncable/entry.h" | 17 #include "sync/syncable/entry.h" |
| 19 #include "sync/syncable/mutable_entry.h" | 18 #include "sync/syncable/mutable_entry.h" |
| 20 #include "sync/syncable/read_transaction.h" | 19 #include "sync/syncable/read_transaction.h" |
| 20 #include "sync/syncable/syncable_proto_util.h" | |
| 21 #include "sync/syncable/syncable_util.h" | 21 #include "sync/syncable/syncable_util.h" |
| 22 #include "sync/syncable/write_transaction.h" | 22 #include "sync/syncable/write_transaction.h" |
| 23 #include "sync/util/time.h" | 23 #include "sync/util/time.h" |
| 24 | 24 |
| 25 using std::set; | 25 using std::set; |
| 26 using std::string; | 26 using std::string; |
| 27 using std::vector; | 27 using std::vector; |
| 28 using sync_pb::CommitResponse; | |
| 28 | 29 |
| 29 namespace syncer { | 30 namespace syncer { |
| 30 | 31 |
| 31 using sessions::OrderedCommitSet; | 32 using sessions::OrderedCommitSet; |
| 32 using sessions::StatusController; | 33 using sessions::StatusController; |
| 33 using sessions::SyncSession; | 34 using sessions::SyncSession; |
| 34 using sessions::ConflictProgress; | 35 using sessions::ConflictProgress; |
| 35 using syncable::WriteTransaction; | 36 using syncable::WriteTransaction; |
| 36 using syncable::MutableEntry; | 37 using syncable::MutableEntry; |
| 37 using syncable::Entry; | 38 using syncable::Entry; |
| 38 using syncable::BASE_VERSION; | 39 using syncable::BASE_VERSION; |
| 39 using syncable::GET_BY_ID; | 40 using syncable::GET_BY_ID; |
| 40 using syncable::ID; | 41 using syncable::ID; |
| 41 using syncable::IS_DEL; | 42 using syncable::IS_DEL; |
| 42 using syncable::IS_DIR; | 43 using syncable::IS_DIR; |
| 43 using syncable::IS_UNAPPLIED_UPDATE; | 44 using syncable::IS_UNAPPLIED_UPDATE; |
| 44 using syncable::IS_UNSYNCED; | 45 using syncable::IS_UNSYNCED; |
| 45 using syncable::PARENT_ID; | 46 using syncable::PARENT_ID; |
| 46 using syncable::SERVER_IS_DEL; | 47 using syncable::SERVER_IS_DEL; |
| 47 using syncable::SERVER_PARENT_ID; | 48 using syncable::SERVER_PARENT_ID; |
| 48 using syncable::SERVER_POSITION_IN_PARENT; | 49 using syncable::SERVER_POSITION_IN_PARENT; |
| 49 using syncable::SERVER_VERSION; | 50 using syncable::SERVER_VERSION; |
| 50 using syncable::SYNCER; | 51 using syncable::SYNCER; |
| 51 using syncable::SYNCING; | 52 using syncable::SYNCING; |
| 52 | 53 |
| 53 ProcessCommitResponseCommand::ProcessCommitResponseCommand( | 54 ProcessCommitResponseCommand::ProcessCommitResponseCommand( |
| 54 const sessions::OrderedCommitSet& commit_set, | 55 const sessions::OrderedCommitSet& commit_set, |
| 55 const ClientToServerMessage& commit_message, | 56 const sync_pb::ClientToServerMessage& commit_message, |
| 56 const ClientToServerResponse& commit_response) | 57 const sync_pb::ClientToServerResponse& commit_response) |
| 57 : commit_set_(commit_set), | 58 : commit_set_(commit_set), |
| 58 commit_message_(commit_message), | 59 commit_message_(commit_message), |
| 59 commit_response_(commit_response) { | 60 commit_response_(commit_response) { |
| 60 } | 61 } |
| 61 | 62 |
| 62 ProcessCommitResponseCommand::~ProcessCommitResponseCommand() {} | 63 ProcessCommitResponseCommand::~ProcessCommitResponseCommand() {} |
| 63 | 64 |
| 64 std::set<ModelSafeGroup> ProcessCommitResponseCommand::GetGroupsToChange( | 65 std::set<ModelSafeGroup> ProcessCommitResponseCommand::GetGroupsToChange( |
| 65 const sessions::SyncSession& session) const { | 66 const sessions::SyncSession& session) const { |
| 66 std::set<ModelSafeGroup> groups_with_commits; | 67 std::set<ModelSafeGroup> groups_with_commits; |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 182 // | 183 // |
| 183 // TODO: Remove this option when the CONFLICT return value is fully | 184 // TODO: Remove this option when the CONFLICT return value is fully |
| 184 // deprecated. | 185 // deprecated. |
| 185 return SERVER_RETURN_TRANSIENT_ERROR; | 186 return SERVER_RETURN_TRANSIENT_ERROR; |
| 186 } else { | 187 } else { |
| 187 LOG(FATAL) << "Inconsistent counts when processing commit response"; | 188 LOG(FATAL) << "Inconsistent counts when processing commit response"; |
| 188 return SYNCER_OK; | 189 return SYNCER_OK; |
| 189 } | 190 } |
| 190 } | 191 } |
| 191 | 192 |
| 192 void LogServerError(const CommitResponse_EntryResponse& res) { | 193 void LogServerError(const sync_pb::CommitResponse_EntryResponse& res) { |
| 193 if (res.has_error_message()) | 194 if (res.has_error_message()) |
| 194 LOG(WARNING) << " " << res.error_message(); | 195 LOG(WARNING) << " " << res.error_message(); |
| 195 else | 196 else |
| 196 LOG(WARNING) << " No detailed error message returned from server"; | 197 LOG(WARNING) << " No detailed error message returned from server"; |
| 197 } | 198 } |
| 198 | 199 |
| 199 CommitResponse::ResponseType | 200 CommitResponse::ResponseType |
| 200 ProcessCommitResponseCommand::ProcessSingleCommitResponse( | 201 ProcessCommitResponseCommand::ProcessSingleCommitResponse( |
| 201 syncable::WriteTransaction* trans, | 202 syncable::WriteTransaction* trans, |
| 202 const sync_pb::CommitResponse_EntryResponse& pb_server_entry, | 203 const sync_pb::CommitResponse_EntryResponse& server_entry, |
| 203 const sync_pb::SyncEntity& commit_request_entry, | 204 const sync_pb::SyncEntity& commit_request_entry, |
| 204 const syncable::Id& pre_commit_id, | 205 const syncable::Id& pre_commit_id, |
| 205 set<syncable::Id>* deleted_folders) { | 206 set<syncable::Id>* deleted_folders) { |
| 206 | 207 |
| 207 const CommitResponse_EntryResponse& server_entry = | |
| 208 *static_cast<const CommitResponse_EntryResponse*>(&pb_server_entry); | |
| 209 MutableEntry local_entry(trans, GET_BY_ID, pre_commit_id); | 208 MutableEntry local_entry(trans, GET_BY_ID, pre_commit_id); |
| 210 CHECK(local_entry.good()); | 209 CHECK(local_entry.good()); |
| 211 bool syncing_was_set = local_entry.Get(SYNCING); | 210 bool syncing_was_set = local_entry.Get(SYNCING); |
| 212 local_entry.Put(SYNCING, false); | 211 local_entry.Put(SYNCING, false); |
| 213 | 212 |
| 214 CommitResponse::ResponseType response = (CommitResponse::ResponseType) | 213 CommitResponse::ResponseType response = (CommitResponse::ResponseType) |
| 215 server_entry.response_type(); | 214 server_entry.response_type(); |
| 216 if (!CommitResponse::ResponseType_IsValid(response)) { | 215 if (!CommitResponse::ResponseType_IsValid(response)) { |
| 217 LOG(ERROR) << "Commit response has unknown response type! Possibly out " | 216 LOG(ERROR) << "Commit response has unknown response type! Possibly out " |
| 218 "of date client?"; | 217 "of date client?"; |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 242 } | 241 } |
| 243 if (!server_entry.has_id_string()) { | 242 if (!server_entry.has_id_string()) { |
| 244 LOG(ERROR) << "Commit response has no id"; | 243 LOG(ERROR) << "Commit response has no id"; |
| 245 return CommitResponse::INVALID_MESSAGE; | 244 return CommitResponse::INVALID_MESSAGE; |
| 246 } | 245 } |
| 247 | 246 |
| 248 // Implied by the IsValid call above, but here for clarity. | 247 // Implied by the IsValid call above, but here for clarity. |
| 249 DCHECK_EQ(CommitResponse::SUCCESS, response) << response; | 248 DCHECK_EQ(CommitResponse::SUCCESS, response) << response; |
| 250 // Check to see if we've been given the ID of an existing entry. If so treat | 249 // Check to see if we've been given the ID of an existing entry. If so treat |
| 251 // it as an error response and retry later. | 250 // it as an error response and retry later. |
| 252 if (pre_commit_id != server_entry.id()) { | 251 syncable::Id server_entry_id = SyncableIdFromProto(server_entry.id_string()); |
|
akalin
2012/07/11 23:10:40
const &
rlarocque
2012/07/11 23:45:36
Done.
| |
| 253 Entry e(trans, GET_BY_ID, server_entry.id()); | 252 if (pre_commit_id != server_entry_id) { |
| 253 Entry e(trans, GET_BY_ID, server_entry_id); | |
| 254 if (e.good()) { | 254 if (e.good()) { |
| 255 LOG(ERROR) << "Got duplicate id when commiting id: " << pre_commit_id << | 255 LOG(ERROR) << "Got duplicate id when commiting id: " << pre_commit_id << |
| 256 ". Treating as an error return"; | 256 ". Treating as an error return"; |
| 257 return CommitResponse::INVALID_MESSAGE; | 257 return CommitResponse::INVALID_MESSAGE; |
| 258 } | 258 } |
| 259 } | 259 } |
| 260 | 260 |
| 261 if (server_entry.version() == 0) { | 261 if (server_entry.version() == 0) { |
| 262 LOG(WARNING) << "Server returned a zero version on a commit response."; | 262 LOG(WARNING) << "Server returned a zero version on a commit response."; |
| 263 } | 263 } |
| 264 | 264 |
| 265 ProcessSuccessfulCommitResponse(commit_request_entry, server_entry, | 265 ProcessSuccessfulCommitResponse(commit_request_entry, server_entry, |
| 266 pre_commit_id, &local_entry, syncing_was_set, deleted_folders); | 266 pre_commit_id, &local_entry, syncing_was_set, deleted_folders); |
| 267 return response; | 267 return response; |
| 268 } | 268 } |
| 269 | 269 |
| 270 const string& ProcessCommitResponseCommand::GetResultingPostCommitName( | 270 const string& ProcessCommitResponseCommand::GetResultingPostCommitName( |
| 271 const sync_pb::SyncEntity& committed_entry, | 271 const sync_pb::SyncEntity& committed_entry, |
| 272 const CommitResponse_EntryResponse& entry_response) { | 272 const sync_pb::CommitResponse_EntryResponse& entry_response) { |
| 273 const string& response_name = | 273 const string& response_name = |
| 274 SyncerProtoUtil::NameFromCommitEntryResponse(entry_response); | 274 SyncerProtoUtil::NameFromCommitEntryResponse(entry_response); |
| 275 if (!response_name.empty()) | 275 if (!response_name.empty()) |
| 276 return response_name; | 276 return response_name; |
| 277 return SyncerProtoUtil::NameFromSyncEntity(committed_entry); | 277 return SyncerProtoUtil::NameFromSyncEntity(committed_entry); |
| 278 } | 278 } |
| 279 | 279 |
| 280 bool ProcessCommitResponseCommand::UpdateVersionAfterCommit( | 280 bool ProcessCommitResponseCommand::UpdateVersionAfterCommit( |
| 281 const sync_pb::SyncEntity& committed_entry, | 281 const sync_pb::SyncEntity& committed_entry, |
| 282 const CommitResponse_EntryResponse& entry_response, | 282 const sync_pb::CommitResponse_EntryResponse& entry_response, |
| 283 const syncable::Id& pre_commit_id, | 283 const syncable::Id& pre_commit_id, |
| 284 syncable::MutableEntry* local_entry) { | 284 syncable::MutableEntry* local_entry) { |
| 285 int64 old_version = local_entry->Get(BASE_VERSION); | 285 int64 old_version = local_entry->Get(BASE_VERSION); |
| 286 int64 new_version = entry_response.version(); | 286 int64 new_version = entry_response.version(); |
| 287 bool bad_commit_version = false; | 287 bool bad_commit_version = false; |
| 288 if (committed_entry.deleted() && | 288 if (committed_entry.deleted() && |
| 289 !local_entry->Get(syncable::UNIQUE_CLIENT_TAG).empty()) { | 289 !local_entry->Get(syncable::UNIQUE_CLIENT_TAG).empty()) { |
| 290 // If the item was deleted, and it's undeletable (uses the client tag), | 290 // If the item was deleted, and it's undeletable (uses the client tag), |
| 291 // change the version back to zero. We must set the version to zero so | 291 // change the version back to zero. We must set the version to zero so |
| 292 // that the server knows to re-create the item if it gets committed | 292 // that the server knows to re-create the item if it gets committed |
| 293 // later for undeletion. | 293 // later for undeletion. |
| 294 new_version = 0; | 294 new_version = 0; |
| 295 } else if (!pre_commit_id.ServerKnows()) { | 295 } else if (!pre_commit_id.ServerKnows()) { |
| 296 bad_commit_version = 0 == new_version; | 296 bad_commit_version = 0 == new_version; |
| 297 } else { | 297 } else { |
| 298 bad_commit_version = old_version > new_version; | 298 bad_commit_version = old_version > new_version; |
| 299 } | 299 } |
| 300 if (bad_commit_version) { | 300 if (bad_commit_version) { |
| 301 LOG(ERROR) << "Bad version in commit return for " << *local_entry | 301 LOG(ERROR) << "Bad version in commit return for " << *local_entry |
| 302 << " new_id:" << entry_response.id() << " new_version:" | 302 << " new_id:" << SyncableIdFromProto(entry_response.id_string()) |
| 303 << entry_response.version(); | 303 << " new_version:" << entry_response.version(); |
| 304 return false; | 304 return false; |
| 305 } | 305 } |
| 306 | 306 |
| 307 // Update the base version and server version. The base version must change | 307 // Update the base version and server version. The base version must change |
| 308 // here, even if syncing_was_set is false; that's because local changes were | 308 // here, even if syncing_was_set is false; that's because local changes were |
| 309 // on top of the successfully committed version. | 309 // on top of the successfully committed version. |
| 310 local_entry->Put(BASE_VERSION, new_version); | 310 local_entry->Put(BASE_VERSION, new_version); |
| 311 DVLOG(1) << "Commit is changing base version of " << local_entry->Get(ID) | 311 DVLOG(1) << "Commit is changing base version of " << local_entry->Get(ID) |
| 312 << " to: " << new_version; | 312 << " to: " << new_version; |
| 313 local_entry->Put(SERVER_VERSION, new_version); | 313 local_entry->Put(SERVER_VERSION, new_version); |
| 314 return true; | 314 return true; |
| 315 } | 315 } |
| 316 | 316 |
| 317 bool ProcessCommitResponseCommand::ChangeIdAfterCommit( | 317 bool ProcessCommitResponseCommand::ChangeIdAfterCommit( |
| 318 const CommitResponse_EntryResponse& entry_response, | 318 const sync_pb::CommitResponse_EntryResponse& entry_response, |
| 319 const syncable::Id& pre_commit_id, | 319 const syncable::Id& pre_commit_id, |
| 320 syncable::MutableEntry* local_entry) { | 320 syncable::MutableEntry* local_entry) { |
| 321 syncable::WriteTransaction* trans = local_entry->write_transaction(); | 321 syncable::WriteTransaction* trans = local_entry->write_transaction(); |
| 322 if (entry_response.id() != pre_commit_id) { | 322 syncable::Id entry_response_id = |
|
akalin
2012/07/11 23:10:40
const &
rlarocque
2012/07/11 23:45:36
Done.
| |
| 323 SyncableIdFromProto(entry_response.id_string()); | |
| 324 if (entry_response_id != pre_commit_id) { | |
| 323 if (pre_commit_id.ServerKnows()) { | 325 if (pre_commit_id.ServerKnows()) { |
| 324 // The server can sometimes generate a new ID on commit; for example, | 326 // The server can sometimes generate a new ID on commit; for example, |
| 325 // when committing an undeletion. | 327 // when committing an undeletion. |
| 326 DVLOG(1) << " ID changed while committing an old entry. " | 328 DVLOG(1) << " ID changed while committing an old entry. " |
| 327 << pre_commit_id << " became " << entry_response.id() << "."; | 329 << pre_commit_id << " became " << entry_response_id << "."; |
| 328 } | 330 } |
| 329 MutableEntry same_id(trans, GET_BY_ID, entry_response.id()); | 331 MutableEntry same_id(trans, GET_BY_ID, entry_response_id); |
| 330 // We should trap this before this function. | 332 // We should trap this before this function. |
| 331 if (same_id.good()) { | 333 if (same_id.good()) { |
| 332 LOG(ERROR) << "ID clash with id " << entry_response.id() | 334 LOG(ERROR) << "ID clash with id " << entry_response_id |
| 333 << " during commit " << same_id; | 335 << " during commit " << same_id; |
| 334 return false; | 336 return false; |
| 335 } | 337 } |
| 336 ChangeEntryIDAndUpdateChildren(trans, local_entry, entry_response.id()); | 338 ChangeEntryIDAndUpdateChildren(trans, local_entry, entry_response_id); |
| 337 DVLOG(1) << "Changing ID to " << entry_response.id(); | 339 DVLOG(1) << "Changing ID to " << entry_response_id; |
| 338 } | 340 } |
| 339 return true; | 341 return true; |
| 340 } | 342 } |
| 341 | 343 |
| 342 void ProcessCommitResponseCommand::UpdateServerFieldsAfterCommit( | 344 void ProcessCommitResponseCommand::UpdateServerFieldsAfterCommit( |
| 343 const sync_pb::SyncEntity& committed_entry, | 345 const sync_pb::SyncEntity& committed_entry, |
| 344 const CommitResponse_EntryResponse& entry_response, | 346 const sync_pb::CommitResponse_EntryResponse& entry_response, |
| 345 syncable::MutableEntry* local_entry) { | 347 syncable::MutableEntry* local_entry) { |
| 346 | 348 |
| 347 // We just committed an entry successfully, and now we want to make our view | 349 // We just committed an entry successfully, and now we want to make our view |
| 348 // of the server state consistent with the server state. We must be careful; | 350 // of the server state consistent with the server state. We must be careful; |
| 349 // |entry_response| and |committed_entry| have some identically named | 351 // |entry_response| and |committed_entry| have some identically named |
| 350 // fields. We only want to consider fields from |committed_entry| when there | 352 // fields. We only want to consider fields from |committed_entry| when there |
| 351 // is not an overriding field in the |entry_response|. We do not want to | 353 // is not an overriding field in the |entry_response|. We do not want to |
| 352 // update the server data from the local data in the entry -- it's possible | 354 // update the server data from the local data in the entry -- it's possible |
| 353 // that the local data changed during the commit, and even if not, the server | 355 // that the local data changed during the commit, and even if not, the server |
| 354 // has the last word on the values of several properties. | 356 // has the last word on the values of several properties. |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 385 if (local_entry->Get(IS_UNAPPLIED_UPDATE)) { | 387 if (local_entry->Get(IS_UNAPPLIED_UPDATE)) { |
| 386 // This shouldn't happen; an unapplied update shouldn't be committed, and | 388 // This shouldn't happen; an unapplied update shouldn't be committed, and |
| 387 // if it were, the commit should have failed. But if it does happen: we've | 389 // if it were, the commit should have failed. But if it does happen: we've |
| 388 // just overwritten the update info, so clear the flag. | 390 // just overwritten the update info, so clear the flag. |
| 389 local_entry->Put(IS_UNAPPLIED_UPDATE, false); | 391 local_entry->Put(IS_UNAPPLIED_UPDATE, false); |
| 390 } | 392 } |
| 391 } | 393 } |
| 392 | 394 |
| 393 void ProcessCommitResponseCommand::OverrideClientFieldsAfterCommit( | 395 void ProcessCommitResponseCommand::OverrideClientFieldsAfterCommit( |
| 394 const sync_pb::SyncEntity& committed_entry, | 396 const sync_pb::SyncEntity& committed_entry, |
| 395 const CommitResponse_EntryResponse& entry_response, | 397 const sync_pb::CommitResponse_EntryResponse& entry_response, |
| 396 syncable::MutableEntry* local_entry) { | 398 syncable::MutableEntry* local_entry) { |
| 397 if (committed_entry.deleted()) { | 399 if (committed_entry.deleted()) { |
| 398 // If an entry's been deleted, nothing else matters. | 400 // If an entry's been deleted, nothing else matters. |
| 399 DCHECK(local_entry->Get(IS_DEL)); | 401 DCHECK(local_entry->Get(IS_DEL)); |
| 400 return; | 402 return; |
| 401 } | 403 } |
| 402 | 404 |
| 403 // Update the name. | 405 // Update the name. |
| 404 const string& server_name = | 406 const string& server_name = |
| 405 GetResultingPostCommitName(committed_entry, entry_response); | 407 GetResultingPostCommitName(committed_entry, entry_response); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 425 local_entry->Get(PARENT_ID)); | 427 local_entry->Get(PARENT_ID)); |
| 426 if (!local_entry->PutPredecessor(new_prev)) { | 428 if (!local_entry->PutPredecessor(new_prev)) { |
| 427 // TODO(lipalani) : Propagate the error to caller. crbug.com/100444. | 429 // TODO(lipalani) : Propagate the error to caller. crbug.com/100444. |
| 428 NOTREACHED(); | 430 NOTREACHED(); |
| 429 } | 431 } |
| 430 } | 432 } |
| 431 } | 433 } |
| 432 | 434 |
| 433 void ProcessCommitResponseCommand::ProcessSuccessfulCommitResponse( | 435 void ProcessCommitResponseCommand::ProcessSuccessfulCommitResponse( |
| 434 const sync_pb::SyncEntity& committed_entry, | 436 const sync_pb::SyncEntity& committed_entry, |
| 435 const CommitResponse_EntryResponse& entry_response, | 437 const sync_pb::CommitResponse_EntryResponse& entry_response, |
| 436 const syncable::Id& pre_commit_id, syncable::MutableEntry* local_entry, | 438 const syncable::Id& pre_commit_id, syncable::MutableEntry* local_entry, |
| 437 bool syncing_was_set, set<syncable::Id>* deleted_folders) { | 439 bool syncing_was_set, set<syncable::Id>* deleted_folders) { |
| 438 DCHECK(local_entry->Get(IS_UNSYNCED)); | 440 DCHECK(local_entry->Get(IS_UNSYNCED)); |
| 439 | 441 |
| 440 // Update SERVER_VERSION and BASE_VERSION. | 442 // Update SERVER_VERSION and BASE_VERSION. |
| 441 if (!UpdateVersionAfterCommit(committed_entry, entry_response, pre_commit_id, | 443 if (!UpdateVersionAfterCommit(committed_entry, entry_response, pre_commit_id, |
| 442 local_entry)) { | 444 local_entry)) { |
| 443 LOG(ERROR) << "Bad version in commit return for " << *local_entry | 445 LOG(ERROR) << "Bad version in commit return for " << *local_entry |
| 444 << " new_id:" << entry_response.id() << " new_version:" | 446 << " new_id:" << SyncableIdFromProto(entry_response.id_string()) |
| 445 << entry_response.version(); | 447 << " new_version:" << entry_response.version(); |
| 446 return; | 448 return; |
| 447 } | 449 } |
| 448 | 450 |
| 449 // If the server gave us a new ID, apply it. | 451 // If the server gave us a new ID, apply it. |
| 450 if (!ChangeIdAfterCommit(entry_response, pre_commit_id, local_entry)) { | 452 if (!ChangeIdAfterCommit(entry_response, pre_commit_id, local_entry)) { |
| 451 return; | 453 return; |
| 452 } | 454 } |
| 453 | 455 |
| 454 // Update our stored copy of the server state. | 456 // Update our stored copy of the server state. |
| 455 UpdateServerFieldsAfterCommit(committed_entry, entry_response, local_entry); | 457 UpdateServerFieldsAfterCommit(committed_entry, entry_response, local_entry); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 469 // been recursively deleted. | 471 // been recursively deleted. |
| 470 // TODO(nick): Here, commit_message.deleted() would be more correct than | 472 // TODO(nick): Here, commit_message.deleted() would be more correct than |
| 471 // local_entry->Get(IS_DEL). For example, an item could be renamed, and then | 473 // local_entry->Get(IS_DEL). For example, an item could be renamed, and then |
| 472 // deleted during the commit of the rename. Unit test & fix. | 474 // deleted during the commit of the rename. Unit test & fix. |
| 473 if (local_entry->Get(IS_DIR) && local_entry->Get(IS_DEL)) { | 475 if (local_entry->Get(IS_DIR) && local_entry->Get(IS_DEL)) { |
| 474 deleted_folders->insert(local_entry->Get(ID)); | 476 deleted_folders->insert(local_entry->Get(ID)); |
| 475 } | 477 } |
| 476 } | 478 } |
| 477 | 479 |
| 478 } // namespace syncer | 480 } // namespace syncer |
| OLD | NEW |