Skip to content

Commit 9dbba37

Browse files
janezhang10meta-codesync[bot]
authored andcommitted
Add FakeBackingStore::co_getBlobAuxData
Summary: Add coroutine (now_task) version of getBlobAuxData for `getBlake3` migration. Reviewed By: SBones Differential Revision: D102858780 fbshipit-source-id: 3e9177da8dd515d26f1e1121931b7dd0b1446547
1 parent eac5766 commit 9dbba37

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

eden/fs/testharness/FakeBackingStore.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,33 @@ FakeBackingStore::getBlobAuxData(
248248
.semi();
249249
}
250250

251+
folly::coro::now_task<BackingStore::GetBlobAuxResult>
252+
FakeBackingStore::co_getBlobAuxData(
253+
const ObjectId& id,
254+
const ObjectFetchContextPtr& context) {
255+
{
256+
auto data = data_.wlock();
257+
data->auxDataLookups.push_back(id);
258+
}
259+
260+
if (serverState_) {
261+
co_await serverState_->getFaultInjector().co_checkAsync(
262+
"getBlobAuxData", id);
263+
}
264+
265+
auto blobResult = co_await co_getBlob(id, context);
266+
co_return BackingStore::GetBlobAuxResult{
267+
std::make_shared<BlobAuxDataPtr::element_type>(
268+
Hash20::sha1(blobResult.blob->getContents()),
269+
blake3Key_ ? Hash32::keyedBlake3(
270+
folly::ByteRange{folly::StringPiece{
271+
blake3Key_->data(), blake3Key_->size()}},
272+
blobResult.blob->getContents())
273+
: Hash32::blake3(blobResult.blob->getContents()),
274+
blobResult.blob->getSize()),
275+
blobResult.origin};
276+
}
277+
251278
ImmediateFuture<BackingStore::GetGlobFilesResult>
252279
FakeBackingStore::getGlobFiles(
253280
const RootId& id,

eden/fs/testharness/FakeBackingStore.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,9 @@ class FakeBackingStore final : public BackingStore {
251251
folly::SemiFuture<GetBlobAuxResult> getBlobAuxData(
252252
const ObjectId& id,
253253
const ObjectFetchContextPtr& context) override;
254+
folly::coro::now_task<GetBlobAuxResult> co_getBlobAuxData(
255+
const ObjectId& id,
256+
const ObjectFetchContextPtr& context);
254257
ImmediateFuture<GetGlobFilesResult> getGlobFiles(
255258
const RootId& id,
256259
const std::vector<std::string>& globs,

0 commit comments

Comments
 (0)