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

Unified Diff: sync/internal_api/attachments/on_disk_attachment_store.cc

Issue 982883002: [Sync] Add size and crc32c to AttachmentId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge with master. Created 5 years, 9 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
Index: sync/internal_api/attachments/on_disk_attachment_store.cc
diff --git a/sync/internal_api/attachments/on_disk_attachment_store.cc b/sync/internal_api/attachments/on_disk_attachment_store.cc
index ec6fc75931bd9283d50033f4b055f9f52f514717..699e1f5add122106a7f7030881e3c9731d295c2d 100644
--- a/sync/internal_api/attachments/on_disk_attachment_store.cc
+++ b/sync/internal_api/attachments/on_disk_attachment_store.cc
@@ -319,12 +319,18 @@ scoped_ptr<Attachment> OnDiskAttachmentStore::ReadSingleAttachment(
scoped_refptr<base::RefCountedMemory> data =
base::RefCountedString::TakeString(&data_str);
uint32_t crc32c = ComputeCrc32c(data);
- if (record_metadata.has_crc32c() && record_metadata.crc32c() != crc32c) {
- DVLOG(1) << "Attachment crc does not match";
- return attachment.Pass();
+ if (record_metadata.has_crc32c()) {
+ if (record_metadata.crc32c() != crc32c) {
+ DVLOG(1) << "Attachment crc32c does not match value read from store";
+ return attachment.Pass();
+ }
+ if (record_metadata.crc32c() != attachment_id.GetCrc32c()) {
+ DVLOG(1) << "Attachment crc32c does not match value in AttachmentId";
+ return attachment.Pass();
+ }
}
attachment.reset(
- new Attachment(Attachment::CreateFromParts(attachment_id, data, crc32c)));
+ new Attachment(Attachment::CreateFromParts(attachment_id, data)));
return attachment.Pass();
}

Powered by Google App Engine
This is Rietveld 408576698