diff --git a/repertory/librepertory/src/drives/winfsp/winfsp_drive.cpp b/repertory/librepertory/src/drives/winfsp/winfsp_drive.cpp index ce49421c..4abf8033 100644 --- a/repertory/librepertory/src/drives/winfsp/winfsp_drive.cpp +++ b/repertory/librepertory/src/drives/winfsp/winfsp_drive.cpp @@ -479,8 +479,7 @@ auto winfsp_drive::get_security_by_name( if (descriptor_size != nullptr) { ULONG size{}; PSECURITY_DESCRIPTOR sec_desc{}; - - if (::ConvertStringSecurityDescriptorToSecurityDescriptor( + if (::ConvertStringSecurityDescriptorToSecurityDescriptorA( "O:BAG:BAD:P(A;;FA;;;SY)(A;;FA;;;BA)(A;;FA;;;WD)", SDDL_REVISION_1, &sec_desc, &size) != 0) { if (size > *descriptor_size) { @@ -511,6 +510,11 @@ auto winfsp_drive::GetSecurityByName(PWSTR file_name, PUINT32 attributes, std::uint64_t sds = descriptor_size == nullptr ? 0U : *descriptor_size; auto ret = get_security_by_name(file_name, attributes, descriptor, sds > 0U ? &sds : nullptr); + if (attributes != nullptr) { + event_system::instance().raise( + std::string{function_name}, api_path, + std::to_string(*attributes & FILE_ATTRIBUTE_DIRECTORY)); + } if (sds != 0U) { *descriptor_size = static_cast(sds); } @@ -709,6 +713,8 @@ auto winfsp_drive::Open(PWSTR file_name, UINT32 create_options, std::uint64_t handle{}; std::shared_ptr file; error = fm_->open(api_path, directory, ofd, handle, file); + event_system::instance().raise( + std::string{function_name}, api_path, std::to_string(handle)); if (error == api_error::success) { api_meta_map meta; error = provider_.get_item_meta(api_path, meta); @@ -899,6 +905,7 @@ auto winfsp_drive::ReadDirectory(PVOID /*file_node*/, PVOID file_desc, static constexpr const std::string_view function_name{ static_cast(__FUNCTION__), }; + event_system::instance().raise(std::string{function_name}, "", ""); std::string api_path; auto error = api_error::invalid_handle; diff --git a/repertory/librepertory/src/providers/encrypt/encrypt_provider.cpp b/repertory/librepertory/src/providers/encrypt/encrypt_provider.cpp index 4b38598e..106f4cec 100644 --- a/repertory/librepertory/src/providers/encrypt/encrypt_provider.cpp +++ b/repertory/librepertory/src/providers/encrypt/encrypt_provider.cpp @@ -72,9 +72,16 @@ encrypt_provider::encrypt_provider(app_config &config) : config_(config) {} auto encrypt_provider::create_api_file( const std::string &api_path, bool directory, const std::string &source_path) -> api_file { + static constexpr const std::string_view function_name{ + static_cast(__FUNCTION__), + }; + #if defined(_WIN32) struct _stat64 buf {}; - _stat64(source_path.c_str(), &buf); + auto res = _stat64(source_path.c_str(), &buf); + event_system::instance().raise( + std::string{function_name}, source_path, + std::to_string(res) + ':' + std::to_string(directory)); #else struct stat buf {}; stat(source_path.c_str(), &buf); @@ -130,9 +137,15 @@ auto encrypt_provider::create_api_file( void encrypt_provider::create_item_meta(api_meta_map &meta, bool directory, const api_file &file) { + static constexpr const std::string_view function_name{ + static_cast(__FUNCTION__), + }; + #if defined(_WIN32) struct _stat64 buf {}; - _stat64(file.source_path.c_str(), &buf); + auto res = _stat64(file.source_path.c_str(), &buf); + event_system::instance().raise( + std::string{function_name}, file.source_path, std::to_string(res)); #else struct stat buf {}; stat(file.source_path.c_str(), &buf); @@ -435,9 +448,13 @@ auto encrypt_provider::get_file_list(api_file_list &list) const -> api_error { }; const auto cfg = config_.get_encrypt_config(); + event_system::instance().raise(std::string{function_name}, + cfg.path, ""); try { for (auto &&dir_entry : utils::file::directory{cfg.path}.get_items()) { + event_system::instance().raise( + std::string{function_name}, cfg.path, dir_entry->get_path()); std::string api_path{}; if (process_directory_entry(*dir_entry.get(), cfg, api_path)) { list.emplace_back(create_api_file( @@ -486,6 +503,10 @@ auto encrypt_provider::get_file_size( auto encrypt_provider::get_filesystem_item( const std::string &api_path, bool directory, filesystem_item &fsi) const -> api_error { + static constexpr const std::string_view function_name{ + static_cast(__FUNCTION__), + }; + auto result = db::db_select{*db_, source_table} .column("source_path") .where("api_path") @@ -498,6 +519,9 @@ auto encrypt_provider::get_filesystem_item( auto source_path = row->get_column("source_path").get_value(); + event_system::instance().raise( + std::string{function_name}, source_path, std::to_string(directory)); + if (directory) { result = db::db_select{*db_, directory_table} .column("api_path") @@ -588,6 +612,10 @@ auto encrypt_provider::get_pinned_files() const -> std::vector { auto encrypt_provider::get_item_meta(const std::string &api_path, api_meta_map &meta) const -> api_error { + static constexpr const std::string_view function_name{ + static_cast(__FUNCTION__), + }; + auto result = db::db_select{*db_, source_table} .column("source_path") .where("api_path") @@ -607,6 +635,8 @@ auto encrypt_provider::get_item_meta(const std::string &api_path, } auto file = create_api_file(api_path, exists, source_path); + event_system::instance().raise( + std::string{function_name}, api_path, exists ? "true" : "false"); create_item_meta(meta, exists, file); return api_error::success; } @@ -695,7 +725,7 @@ auto encrypt_provider::is_file_writeable(const std::string & /*api_path*/) const } auto encrypt_provider::is_online() const -> bool { - return utils::file::file{ + return utils::file::directory{ config_.get_encrypt_config().path, } .exists();