limit directory cache to directory operations
This commit is contained in:
@ -501,28 +501,16 @@ auto fuse_drive::getattr_impl(std::string api_path, struct stat *unix_st)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto found = false;
|
api_meta_map meta{};
|
||||||
directory_cache_->execute_action(parent, [&](directory_iterator &iter) {
|
res = provider_.get_item_meta(api_path, meta);
|
||||||
directory_item dir_item{};
|
if (res != api_error::success) {
|
||||||
found = (iter.get_directory_item(api_path, dir_item) == api_error::success);
|
return res;
|
||||||
if (found) {
|
|
||||||
fuse_drive_base::populate_stat(api_path, dir_item.size, dir_item.meta,
|
|
||||||
dir_item.directory, provider_, unix_st);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (not found) {
|
|
||||||
api_meta_map meta{};
|
|
||||||
res = provider_.get_item_meta(api_path, meta);
|
|
||||||
if (res != api_error::success) {
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
fuse_drive_base::populate_stat(
|
|
||||||
api_path, utils::string::to_uint64(meta[META_SIZE]), meta,
|
|
||||||
utils::string::to_bool(meta[META_DIRECTORY]), provider_, unix_st);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fuse_drive_base::populate_stat(
|
||||||
|
api_path, utils::string::to_uint64(meta[META_SIZE]), meta,
|
||||||
|
utils::string::to_bool(meta[META_DIRECTORY]), provider_, unix_st);
|
||||||
|
|
||||||
return api_error::success;
|
return api_error::success;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -583,24 +571,24 @@ void *fuse_drive::init_impl(struct fuse_conn_info *conn) {
|
|||||||
auto *ret = fuse_drive_base::init_impl(conn);
|
auto *ret = fuse_drive_base::init_impl(conn);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (console_enabled_) {
|
|
||||||
console_consumer_ =
|
|
||||||
std::make_unique<console_consumer>(config_.get_event_level());
|
|
||||||
}
|
|
||||||
|
|
||||||
logging_consumer_ = std::make_unique<logging_consumer>(
|
|
||||||
config_.get_event_level(), config_.get_log_directory());
|
|
||||||
event_system::instance().start();
|
|
||||||
was_mounted_ = true;
|
|
||||||
|
|
||||||
fm_ = std::make_unique<file_manager>(config_, provider_);
|
|
||||||
server_ = std::make_unique<full_server>(config_, provider_, *fm_);
|
|
||||||
if (not provider_.is_read_only()) {
|
|
||||||
eviction_ = std::make_unique<eviction>(provider_, config_, *fm_);
|
|
||||||
}
|
|
||||||
directory_cache_ = std::make_unique<directory_cache>();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (console_enabled_) {
|
||||||
|
console_consumer_ =
|
||||||
|
std::make_unique<console_consumer>(config_.get_event_level());
|
||||||
|
}
|
||||||
|
|
||||||
|
logging_consumer_ = std::make_unique<logging_consumer>(
|
||||||
|
config_.get_event_level(), config_.get_log_directory());
|
||||||
|
event_system::instance().start();
|
||||||
|
was_mounted_ = true;
|
||||||
|
|
||||||
|
fm_ = std::make_unique<file_manager>(config_, provider_);
|
||||||
|
server_ = std::make_unique<full_server>(config_, provider_, *fm_);
|
||||||
|
if (not provider_.is_read_only()) {
|
||||||
|
eviction_ = std::make_unique<eviction>(provider_, config_, *fm_);
|
||||||
|
}
|
||||||
|
|
||||||
|
directory_cache_ = std::make_unique<directory_cache>();
|
||||||
directory_cache_->start();
|
directory_cache_->start();
|
||||||
server_->start();
|
server_->start();
|
||||||
|
|
||||||
@ -907,19 +895,7 @@ auto fuse_drive::getxattr_common(std::string api_path, const char *name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
api_meta_map meta;
|
api_meta_map meta;
|
||||||
auto found{false};
|
res = provider_.get_item_meta(api_path, meta);
|
||||||
directory_cache_->execute_action(
|
|
||||||
utils::path::get_parent_api_path(api_path),
|
|
||||||
[&](directory_iterator &iterator) {
|
|
||||||
directory_item dir_item{};
|
|
||||||
found = (iterator.get_directory_item(api_path, dir_item) ==
|
|
||||||
api_error::success);
|
|
||||||
if (found) {
|
|
||||||
meta = dir_item.meta;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
res = found ? api_error::success : provider_.get_item_meta(api_path, meta);
|
|
||||||
if (res != api_error::success) {
|
if (res != api_error::success) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user