mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 15:27:13 +03:00
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:
parent
1cd4b45988
commit
595de0b045
@ -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(
|
||||
|
@ -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(
|
||||
|
@ -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)] {
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user