Merge remote-tracking branch 'goog/upstream-master' into androidx-platform-dev
* goog/upstream-master:
Sync from upstream.
Change-Id: I59c5686429289baaddf90ed25b3394fe79849580
diff --git a/icing/store/document-store.cc b/icing/store/document-store.cc
index afcae86..d79c861 100644
--- a/icing/store/document-store.cc
+++ b/icing/store/document-store.cc
@@ -839,8 +839,13 @@
usage_store_->CloneUsageScores(/*from_document_id=*/old_document_id,
/*to_document_id=*/new_document_id));
- // Delete the old document.
- ICING_RETURN_IF_ERROR(Delete(old_document_id));
+ // Delete the old document. It's fine if it's not found since it might have
+ // been deleted previously.
+ auto delete_status = Delete(old_document_id);
+ if (!delete_status.ok() && !absl_ports::IsNotFound(delete_status)) {
+ // Real error, pass it up.
+ return delete_status;
+ }
}
if (put_document_stats != nullptr) {
@@ -885,8 +890,9 @@
auto document_log_offset_or = document_id_mapper_->Get(document_id);
if (!document_log_offset_or.ok()) {
- // Since we've just checked that our document_id is valid a few lines above,
- // there's no reason this should fail and an error should never happen.
+ // Since we've just checked that our document_id is valid a few lines
+ // above, there's no reason this should fail and an error should never
+ // happen.
return absl_ports::InternalError("Failed to find document offset.");
}
int64_t document_log_offset = *document_log_offset_or.ValueOrDie();
@@ -998,8 +1004,8 @@
// This would only happen if document_id is out of range of the
// document_id_mapper, meaning we got some invalid document_id. Callers
// should already have checked that their document_id is valid or used
- // DoesDocumentExist(WithStatus). Regardless, return true since the document
- // doesn't exist.
+ // DoesDocumentExist(WithStatus). Regardless, return true since the
+ // document doesn't exist.
return true;
}
int64_t file_offset = *file_offset_or.ValueOrDie();
@@ -1012,8 +1018,8 @@
// This would only happen if document_id is out of range of the
// filter_cache, meaning we got some invalid document_id. Callers should
// already have checked that their document_id is valid or used
- // DoesDocumentExist(WithStatus). Regardless, return true since the document
- // doesn't exist.
+ // DoesDocumentExist(WithStatus). Regardless, return true since the
+ // document doesn't exist.
return true;
}
const DocumentFilterData* filter_data = filter_data_or.ValueOrDie();
@@ -1226,8 +1232,8 @@
continue;
}
- // The document has the desired namespace and schema type, it either exists
- // or has expired.
+ // The document has the desired namespace and schema type, it either
+ // exists or has expired.
libtextclassifier3::Status delete_status = Delete(document_id);
if (absl_ports::IsNotFound(delete_status)) {
continue;
diff --git a/icing/store/document-store_test.cc b/icing/store/document-store_test.cc
index 076d642..ebc5ec3 100644
--- a/icing/store/document-store_test.cc
+++ b/icing/store/document-store_test.cc
@@ -832,6 +832,19 @@
IsOkAndHolds(EqualsProto(message_document)));
}
+TEST_F(DocumentStoreTest, PutDeleteThenPut) {
+ ICING_ASSERT_OK_AND_ASSIGN(
+ DocumentStore::CreateResult create_result,
+ DocumentStore::Create(&filesystem_, document_store_dir_, &fake_clock_,
+ schema_store_.get()));
+ std::unique_ptr<DocumentStore> doc_store =
+ std::move(create_result.document_store);
+ ICING_EXPECT_OK(doc_store->Put(test_document1_));
+ ICING_EXPECT_OK(
+ doc_store->Delete(test_document1_.namespace_(), test_document1_.uri()));
+ ICING_EXPECT_OK(doc_store->Put(test_document1_));
+}
+
TEST_F(DocumentStoreTest, DeletedSchemaTypeFromSchemaStoreRecoversOk) {
SchemaProto schema =
SchemaBuilder()
diff --git a/synced_AOSP_CL_number.txt b/synced_AOSP_CL_number.txt
index e8a1601..6f5faa0 100644
--- a/synced_AOSP_CL_number.txt
+++ b/synced_AOSP_CL_number.txt
@@ -1 +1 @@
-set(synced_AOSP_CL_number=372608866)
+set(synced_AOSP_CL_number=373174102)