Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(753)

Unified Diff: chrome/browser/chromeos/drive/resource_metadata.cc

Issue 138073010: drive: Add resource ID duplication check to ResourceMetadata::RefreshEntry (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/chromeos/drive/resource_metadata_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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))
« no previous file with comments | « no previous file | chrome/browser/chromeos/drive/resource_metadata_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698