| Index: chrome/browser/chromeos/drive/resource_metadata.cc
|
| diff --git a/chrome/browser/chromeos/drive/resource_metadata.cc b/chrome/browser/chromeos/drive/resource_metadata.cc
|
| index 5d2497e5685adc50ac8b172cd1488b1b481ff195..2c873a47b502d3868e4f15da4994322c4bbf7ee7 100644
|
| --- a/chrome/browser/chromeos/drive/resource_metadata.cc
|
| +++ b/chrome/browser/chromeos/drive/resource_metadata.cc
|
| @@ -335,8 +335,6 @@ FileError ResourceMetadata::ReadDirectoryByPath(
|
|
|
| FileError ResourceMetadata::RefreshEntry(const ResourceEntry& entry) {
|
| DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread());
|
| - // TODO(hashimoto): Return an error if the operation will result in having
|
| - // multiple entries with the same resource ID.
|
|
|
| if (!EnoughDiskSpaceIsAvailableForDBOperation(storage_->directory_path()))
|
| return FILE_ERROR_NO_LOCAL_SPACE;
|
| @@ -350,6 +348,24 @@ FileError ResourceMetadata::RefreshEntry(const ResourceEntry& entry) {
|
| entry.file_info().is_directory())
|
| return FILE_ERROR_INVALID_OPERATION;
|
|
|
| + if (!entry.resource_id().empty()) {
|
| + // Multiple entries cannot share the same resource ID.
|
| + std::string local_id;
|
| + FileError error = GetIdByResourceId(entry.resource_id(), &local_id);
|
| + switch (error) {
|
| + case FILE_ERROR_OK:
|
| + if (local_id != entry.local_id())
|
| + return FILE_ERROR_INVALID_OPERATION;
|
| + break;
|
| +
|
| + case FILE_ERROR_NOT_FOUND:
|
| + break;
|
| +
|
| + default:
|
| + return error;
|
| + }
|
| + }
|
| +
|
| // Make sure that the new parent exists and it is a directory.
|
| ResourceEntry new_parent;
|
| if (!storage_->GetEntry(entry.parent_local_id(), &new_parent))
|
|
|