mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 00:45:18 +03:00
8b82dc96cb
Summary: As of right now, opendir is the expensive callbacks due to fetching the sizes for all the files in a directory. This strategy however breaks down when timeouts are added as very large directories would trigger the timeout, not because EdenFS is having a hard time reaching Mononoke, but because of bandwidth limitation. To avoid this issue, we need to have a per-file timeout and thus makes opendir just trigger the futures, but not wait on them. The waiting bit will happen at readdir time which will also enable having a timeout per file. The one drawback to this is that the ObjectFetchContext that is passed in by opendir cannot live long enough to be used in the size future. For now, we can use a null context, but a proper context will need to be passed in, in the future. Reviewed By: wez Differential Revision: D24895089 fbshipit-source-id: e10ceae2f7c49b4a006b15a34f85d06a2863ae3a
49 lines
1.2 KiB
C++
49 lines
1.2 KiB
C++
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This software may be used and distributed according to the terms of the
|
|
* GNU General Public License version 2.
|
|
*/
|
|
|
|
#ifdef _WIN32
|
|
|
|
#include "folly/portability/Windows.h"
|
|
|
|
#include <ProjectedFSLib.h> // @manual
|
|
#include "eden/fs/prjfs/Enumerator.h"
|
|
|
|
namespace facebook {
|
|
namespace eden {
|
|
|
|
Enumerator::Enumerator(std::vector<FileMetadata>&& entryList)
|
|
: metadataList_(std::move(entryList)) {
|
|
std::sort(
|
|
metadataList_.begin(),
|
|
metadataList_.end(),
|
|
[](const FileMetadata& first, const FileMetadata& second) -> bool {
|
|
return (
|
|
PrjFileNameCompare(first.name.c_str(), second.name.c_str()) < 0);
|
|
});
|
|
}
|
|
|
|
FileMetadata* Enumerator::current() {
|
|
for (; listIndex_ < metadataList_.size(); listIndex_++) {
|
|
if (PrjFileNameMatch(
|
|
metadataList_[listIndex_].name.c_str(),
|
|
searchExpression_.c_str())) {
|
|
//
|
|
// Don't increment the index here because we don't know if the caller
|
|
// would be able to use this. The caller should instead call advance() on
|
|
// success.
|
|
//
|
|
return &metadataList_[listIndex_];
|
|
}
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
} // namespace eden
|
|
} // namespace facebook
|
|
|
|
#endif
|