drive: Handle ApplyEntryMap errors correctly

We should not update the local changestamp when something goes wrong.

BUG=255333
TEST=unit_tests

Review URL: https://codereview.chromium.org/256773005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@266576 0039d316-1c4b-4281-b951-d872f2087c98
parent 3a23f63c
...@@ -284,11 +284,12 @@ FileError ChangeListProcessor::ApplyEntryMap( ...@@ -284,11 +284,12 @@ FileError ChangeListProcessor::ApplyEntryMap(
// root entry, but we should better be defensive (see crbug.com/297259). // root entry, but we should better be defensive (see crbug.com/297259).
ResourceEntryMap::iterator it = entries[i]; ResourceEntryMap::iterator it = entries[i];
if (it->first != root.resource_id()) { if (it->first != root.resource_id()) {
// TODO(hashimoto): Handle ApplyEntry errors correctly.
FileError error = ApplyEntry(it->second); FileError error = ApplyEntry(it->second);
DLOG_IF(WARNING, error != FILE_ERROR_OK) if (error != FILE_ERROR_OK) {
<< "ApplyEntry failed: " << FileErrorToString(error) LOG(ERROR) << "ApplyEntry failed: " << FileErrorToString(error)
<< ", title = " << it->second.title(); << ", title = " << it->second.title();
return error;
}
} }
entry_map_.erase(it); entry_map_.erase(it);
} }
...@@ -299,12 +300,21 @@ FileError ChangeListProcessor::ApplyEntryMap( ...@@ -299,12 +300,21 @@ FileError ChangeListProcessor::ApplyEntryMap(
std::string local_id; std::string local_id;
FileError error = resource_metadata_->GetIdByResourceId( FileError error = resource_metadata_->GetIdByResourceId(
deleted_resource_ids[i], &local_id); deleted_resource_ids[i], &local_id);
if (error == FILE_ERROR_OK) switch (error) {
error = resource_metadata_->RemoveEntry(local_id); case FILE_ERROR_OK:
error = resource_metadata_->RemoveEntry(local_id);
DLOG_IF(WARNING, error != FILE_ERROR_OK && error != FILE_ERROR_NOT_FOUND) break;
<< "Failed to delete: " << FileErrorToString(error) case FILE_ERROR_NOT_FOUND:
<< ", resource_id = " << deleted_resource_ids[i]; error = FILE_ERROR_OK;
break;
default:
break;
}
if (error != FILE_ERROR_OK) {
LOG(ERROR) << "Failed to delete: " << FileErrorToString(error)
<< ", resource_id = " << deleted_resource_ids[i];
return error;
}
} }
return FILE_ERROR_OK; return FILE_ERROR_OK;
......
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