Skip to content

Commit 55c032d

Browse files
janezhang10meta-codesync[bot]
authored andcommitted
Add ObjectStore::co_getDigestHash
Summary: Complete getDigestHash coroutine migration by adding ObjectStore.co_getDigestHash. Reviewed By: SBones Differential Revision: D105636960 fbshipit-source-id: afc0385968fb09daafe48dcfe3d732b4a7def73f
1 parent ed5c993 commit 55c032d

4 files changed

Lines changed: 21 additions & 12 deletions

File tree

eden/fs/inodes/TreeInode.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1948,9 +1948,8 @@ folly::coro::now_task<std::optional<Hash32>> TreeInode::co_getDigestHash(
19481948
treeId = state->treeId.value();
19491949
}
19501950
// ObjectStore::getTreeDigestHash has no co_ version yet, bridge via .semi()
1951-
co_return co_await getObjectStore()
1952-
.getTreeDigestHash(treeId, fetchContext)
1953-
.semi();
1951+
co_return co_await getObjectStore().co_getTreeDigestHash(
1952+
treeId, fetchContext);
19541953
}
19551954

19561955
ImmediateFuture<std::optional<uint64_t>> TreeInode::getDigestSize(

eden/fs/inodes/VirtualInode.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -272,17 +272,14 @@ folly::coro::now_task<std::optional<Hash32>> VirtualInode::co_getDigestHash(
272272
} else if (
273273
auto* entry =
274274
std::get_if<UnmaterializedUnloadedBlobDirEntry>(&variant_)) {
275-
co_return co_await objectStore
276-
->getTreeDigestHash(entry->getObjectId(), fetchContext)
277-
.semi();
275+
co_return co_await objectStore->co_getTreeDigestHash(
276+
entry->getObjectId(), fetchContext);
278277
} else if (auto* tree = std::get_if<TreePtr>(&variant_)) {
279-
co_return co_await objectStore
280-
->getTreeDigestHash((*tree)->getObjectId(), fetchContext)
281-
.semi();
278+
co_return co_await objectStore->co_getTreeDigestHash(
279+
(*tree)->getObjectId(), fetchContext);
282280
} else if (auto* treeEntry = std::get_if<TreeEntry>(&variant_)) {
283-
co_return co_await objectStore
284-
->getTreeDigestHash(treeEntry->getObjectId(), fetchContext)
285-
.semi();
281+
co_return co_await objectStore->co_getTreeDigestHash(
282+
treeEntry->getObjectId(), fetchContext);
286283
} else {
287284
co_yield folly::coro::co_error(PathError(
288285
EINVAL, path, std::string_view{"variant is of unhandled type"}));

eden/fs/store/ObjectStore.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,13 @@ ImmediateFuture<std::optional<Hash32>> ObjectStore::getTreeDigestHash(
517517
});
518518
}
519519

520+
folly::coro::now_task<std::optional<Hash32>> ObjectStore::co_getTreeDigestHash(
521+
const ObjectId& id,
522+
const ObjectFetchContextPtr& context) const {
523+
auto auxData = co_await co_getTreeAuxData(id, context);
524+
co_return auxData.has_value() ? auxData->digestHash : std::nullopt;
525+
}
526+
520527
ImmediateFuture<std::optional<uint64_t>> ObjectStore::getTreeDigestSize(
521528
const ObjectId& id,
522529
const ObjectFetchContextPtr& context) const {

eden/fs/store/ObjectStore.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,17 @@ class ObjectStore : public IObjectStore,
251251

252252
/**
253253
* Returns the DigestHash hash of the contents of the tree with the given ID.
254+
*
255+
* DEPRECATED: Use co_getTreeDigestHash instead.
254256
*/
255257
ImmediateFuture<std::optional<Hash32>> getTreeDigestHash(
256258
const ObjectId& id,
257259
const ObjectFetchContextPtr& context) const;
258260

261+
folly::coro::now_task<std::optional<Hash32>> co_getTreeDigestHash(
262+
const ObjectId& id,
263+
const ObjectFetchContextPtr& context) const;
264+
259265
/**
260266
* Returns the digest size of the tree with the given ID.
261267
*/

0 commit comments

Comments
 (0)