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

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

Issue 14249007: chromeos: Perform strict check on parent-shild relationship of DriveResourceMetadata DB (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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/drive_resource_metadata_storage_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/drive/drive_resource_metadata_storage.cc
diff --git a/chrome/browser/chromeos/drive/drive_resource_metadata_storage.cc b/chrome/browser/chromeos/drive/drive_resource_metadata_storage.cc
index 7546b1c434ebc0652d31e9e31b4fbeb6ed126aef..0468f00e40f53a852555dd1adf01a4f6c60059c1 100644
--- a/chrome/browser/chromeos/drive/drive_resource_metadata_storage.cc
+++ b/chrome/browser/chromeos/drive/drive_resource_metadata_storage.cc
@@ -450,6 +450,7 @@ bool DriveResourceMetadataStorageDB::CheckValidity() {
// Check all entires.
size_t num_checked_child_map_entries = 0;
DriveEntryProto entry;
+ std::string serialized_parent_entry;
std::string child_resource_id;
for (it->Next(); it->Valid(); it->Next()) {
// Check if stored data is broken.
@@ -459,9 +460,19 @@ bool DriveResourceMetadataStorageDB::CheckValidity() {
return false;
}
- // Check if parent-child relationship is stored correctly.
if (!entry.parent_resource_id().empty()) {
- leveldb::Status status = child_map_->Get(
+ // Check if the parent entry is stored.
+ leveldb::Status status = resource_map_->Get(
+ options,
+ leveldb::Slice(entry.parent_resource_id()),
+ &serialized_parent_entry);
+ if (!status.ok()) {
+ DLOG(ERROR) << "Can't get parent entry. status = " << status.ToString();
+ return false;
+ }
+
+ // Check if parent-child relationship is stored correctly.
+ status = child_map_->Get(
options,
leveldb::Slice(GetChildMapKey(entry.parent_resource_id(),
entry.base_name())),
« no previous file with comments | « no previous file | chrome/browser/chromeos/drive/drive_resource_metadata_storage_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698