refactor readdirplus dispatcher code

Summary: make changes mentioned in D32771629 (b984929850) comments

Reviewed By: genevievehelsel

Differential Revision: D33146983

fbshipit-source-id: 10a3dc34317f525adf29cf902dd7037e4f80c396
This commit is contained in:
Michael Cuevas 2021-12-15 21:12:42 -08:00 committed by Facebook GitHub Bot
parent e79d41cc77
commit a742a22db7

View File

@ -301,20 +301,11 @@ ImmediateFuture<NfsDispatcher::ReaddirRes> NfsDispatcherImpl::readdirplus(
auto& dirListRef = dirList.getListRef();
std::vector<ImmediateFuture<folly::Unit>> futuresVec{};
for (auto& entry : dirListRef) {
if (entry.name == ".") {
if (entry.name == "." || entry.name == "..") {
futuresVec.push_back(
this->getattr(InodeNumber{entry.fileid}, context)
.thenValue([&entry](struct stat st) {
entry.name_attributes =
statToPostOpAttr(folly::Try<struct stat>(st));
return folly::unit;
}));
} else if (entry.name == "..") {
futuresVec.push_back(
this->getattr(InodeNumber{entry.fileid}, context)
.thenValue([&entry](struct stat st) {
entry.name_attributes =
statToPostOpAttr(folly::Try<struct stat>(st));
.thenTry([&entry](folly::Try<struct stat> st) {
entry.name_attributes = statToPostOpAttr(st);
return folly::unit;
}));
} else {
@ -323,9 +314,8 @@ ImmediateFuture<NfsDispatcher::ReaddirRes> NfsDispatcherImpl::readdirplus(
.thenValue([entry, &context](InodePtr&& inodep) {
return inodep->stat(context);
})
.thenValue([&entry](struct stat st) {
entry.name_attributes =
statToPostOpAttr(folly::Try<struct stat>(st));
.thenTry([&entry](folly::Try<struct stat> st) {
entry.name_attributes = statToPostOpAttr(st);
return folly::unit;
}));
}