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

Unified Diff: chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.cc

Issue 493643002: [SyncFS] Fix reaching NOTREACHED() in MetadataDatabase (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Work for a nit Created 6 years, 4 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/sync_file_system/drive_backend/metadata_database_index_on_disk_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.cc
diff --git a/chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.cc b/chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.cc
index 7520ee3d8f768ebc8450284e38a1a356e3dd73b0..5c1337957930abb1b26a4c6c8a9189311811e6f1 100644
--- a/chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.cc
+++ b/chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.cc
@@ -870,27 +870,28 @@ void MetadataDatabaseIndexOnDisk::AddToPathIndexes(
const std::string prefix =
GenerateTrackerIDByParentAndTitleKeyPrefix(parent_id, title);
- scoped_ptr<LevelDBWrapper::Iterator> itr(db_->NewIterator());
- for (itr->Seek(prefix); itr->Valid(); itr->Next()) {
- std::string id_str;
- if (!RemovePrefix(itr->key().ToString(), prefix, &id_str))
- break;
+ if (!title.empty()) {
+ scoped_ptr<LevelDBWrapper::Iterator> itr(db_->NewIterator());
+ for (itr->Seek(prefix); itr->Valid(); itr->Next()) {
+ std::string id_str;
+ if (!RemovePrefix(itr->key().ToString(), prefix, &id_str))
+ break;
- int64 tracker_id;
- if (!base::StringToInt64(id_str, &tracker_id))
- continue;
- if (tracker_id == new_tracker.tracker_id()) {
- NOTREACHED();
- continue;
- }
+ int64 tracker_id;
+ if (!base::StringToInt64(id_str, &tracker_id))
+ continue;
+ if (tracker_id == new_tracker.tracker_id()) {
+ NOTREACHED();
+ continue;
+ }
- const std::string multi_key =
- GenerateMultiBackingParentAndTitleKey(parent_id, title);
- DVLOG_IF(1, !DBHasKey(multi_key))
- << " Add to multi backing file paths: " << parent_id << " " << title;
- db_->Put(GenerateMultiBackingParentAndTitleKey(parent_id, title),
- std::string());
- break;
+ const std::string multi_key =
+ GenerateMultiBackingParentAndTitleKey(parent_id, title);
+ DVLOG_IF(1, !DBHasKey(multi_key))
+ << " Add to multi backing file paths: " << parent_id << " " << title;
+ db_->Put(multi_key, std::string());
+ break;
+ }
}
AddToTrackerIDSetWithPrefix(
@@ -937,7 +938,7 @@ void MetadataDatabaseIndexOnDisk::UpdateInPathIndexes(
GenerateActiveTrackerIDByParentAndTitleKey(parent_id, title),
prefix, new_tracker);
- if (CountWithPrefix(prefix, tracker_id) != NONE) {
+ if (!title.empty() && CountWithPrefix(prefix, tracker_id) != NONE) {
const std::string multi_backing_key =
GenerateMultiBackingParentAndTitleKey(parent_id, title);
DVLOG_IF(1, !DBHasKey(multi_backing_key))
« no previous file with comments | « no previous file | chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698