prjfs: use ImmediateFuture in PrjfsDispatcher::access

Summary: This moves the conversion to folly::Future up to the caller.

Reviewed By: genevievehelsel

Differential Revision: D31746630

fbshipit-source-id: 522169af5f7b978b88ebc8596558bd5c9b3c2482
This commit is contained in:
Xavier Deguillard 2021-10-26 13:29:00 -07:00 committed by Facebook GitHub Bot
parent 1cd4b45988
commit 595de0b045
4 changed files with 17 additions and 16 deletions

View File

@ -107,24 +107,23 @@ ImmediateFuture<std::optional<LookupResult>> PrjfsDispatcherImpl::lookup(
});
}
folly::Future<bool> PrjfsDispatcherImpl::access(
ImmediateFuture<bool> PrjfsDispatcherImpl::access(
RelativePath path,
ObjectFetchContext& context) {
return mount_->getInode(path, context)
.semi()
.via(&folly::QueuedImmediateExecutor::instance())
.thenValue([](const InodePtr) { return true; })
.thenError(
folly::tag_t<std::system_error>{},
[path = std::move(path)](const std::system_error& ex) {
if (isEnoent(ex)) {
if (path == kDotEdenConfigPath) {
return folly::makeFuture(true);
}
return folly::makeFuture(false);
.thenTry([path = std::move(path)](folly::Try<bool> result) {
if (auto* exc = result.tryGetExceptionObject<std::system_error>()) {
if (isEnoent(*exc)) {
if (path == kDotEdenConfigPath) {
return folly::Try<bool>{true};
} else {
return folly::Try<bool>{false};
}
return folly::makeFuture<bool>(ex);
});
}
}
return result;
});
}
folly::Future<std::string> PrjfsDispatcherImpl::read(

View File

@ -25,7 +25,7 @@ class PrjfsDispatcherImpl : public PrjfsDispatcher {
RelativePath path,
ObjectFetchContext& context) override;
folly::Future<bool> access(RelativePath path, ObjectFetchContext& context)
ImmediateFuture<bool> access(RelativePath path, ObjectFetchContext& context)
override;
folly::Future<std::string> read(

View File

@ -379,7 +379,9 @@ HRESULT PrjfsChannelInner::queryFileName(
} else {
context->sendError(HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND));
}
});
})
.semi()
.via(&folly::QueuedImmediateExecutor::instance());
});
context->catchErrors(std::move(fut)).ensure([context = std::move(context)] {

View File

@ -64,7 +64,7 @@ class PrjfsDispatcher {
/**
* Test if a file with the given name exist
*/
virtual folly::Future<bool> access(
virtual ImmediateFuture<bool> access(
RelativePath path,
ObjectFetchContext& context) = 0;