diff --git a/repertory/librepertory/src/drives/fuse/remotefuse/remote_server.cpp b/repertory/librepertory/src/drives/fuse/remotefuse/remote_server.cpp index ec13e12c..7f5055c5 100644 --- a/repertory/librepertory/src/drives/fuse/remotefuse/remote_server.cpp +++ b/repertory/librepertory/src/drives/fuse/remotefuse/remote_server.cpp @@ -93,6 +93,7 @@ auto remote_server::populate_file_info(const std::string &api_path, : std::to_string(FILE_ATTRIBUTE_ARCHIVE); drive_.set_item_meta(api_path, META_ATTRIBUTES, meta_attributes); } + auto attributes = utils::string::to_uint32(meta_attributes); auto file_size = directory ? 0U : drive_.get_file_size(api_path); populate_file_info(api_path, file_size, attributes, file_info); @@ -1739,22 +1740,41 @@ auto remote_server::update_to_windows_format(const std::string &root_api_path, item[JSON_META][META_MODIFIED] = std::to_string( utils::string::to_uint64(empty_as_zero(item[JSON_META][META_MODIFIED]))); + auto update_meta{false}; if (item[JSON_META][META_WRITTEN].empty() || (item[JSON_META][META_WRITTEN].get() == "0") || (item[JSON_META][META_WRITTEN].get() == std::to_string(utils::time::WIN32_TIME_CONVERSION))) { - drive_.set_item_meta(api_path, META_WRITTEN, - item[JSON_META][META_MODIFIED].get()); - item[JSON_META][META_WRITTEN] = item[JSON_META][META_MODIFIED]; + item[JSON_META][META_WRITTEN] = + item[JSON_META][META_MODIFIED].get(); + update_meta = true; } if (item[JSON_META][META_ATTRIBUTES].empty()) { - item[JSON_META][META_ATTRIBUTES] = - item[JSON_DIRECTORY].get() - ? std::to_string(FILE_ATTRIBUTE_DIRECTORY) - : std::to_string(FILE_ATTRIBUTE_ARCHIVE); - drive_.set_item_meta(api_path, META_ATTRIBUTES, - item[JSON_META][META_ATTRIBUTES].get()); + item[JSON_META][META_ATTRIBUTES] = "0"; + } + + auto attributes = utils::string::to_uint32( + item[JSON_META][META_ATTRIBUTES].get); + if (item[JSON_DIRECTORY].get()) { + if ((attributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY) { + attributes |= FILE_ATTRIBUTE_DIRECTORY; + attributes &= (~FILE_ATTRIBUTE_ARCHIVE); + item[JSON_META][META_ATTRIBUTES] = std::to_string(attributes); + update_meta = true; + } + } else if ((attributes & FILE_ATTRIBUTE_DIRECTORY) == + FILE_ATTRIBUTE_DIRECTORY || + attributes == 0U) { + attributes |= FILE_ATTRIBUTE_ARCHIVE; + attributes &= (~FILE_ATTRIBUTE_DIRECTORY); + item[JSON_META][META_ATTRIBUTES] = std::to_string(attributes); + drive_.set_item_meta(api_path, item[JSON_META]); + update_meta = true; + } + + if (update_meta) { + drive_.set_item_meta(api_path, item[JSON_META]); } return item; diff --git a/support/src/utils/file_directory.cpp b/support/src/utils/file_directory.cpp index c2364420..8870f14e 100644 --- a/support/src/utils/file_directory.cpp +++ b/support/src/utils/file_directory.cpp @@ -86,7 +86,8 @@ auto traverse_directory( struct dirent *de{nullptr}; while (res && (de = readdir(root)) && !is_stop_requested()) { repertory::utils::error::handle_debug( - function_name, fmt::format("item|{}|type|{}", de->d_name, de->d_type)); + function_name, + fmt::format("item|{}|type|{}|{}", de->d_name, de->d_type, DT_DIR)); if (de->d_type == DT_DIR) { if ((std::string_view(de->d_name) == ".") || (std::string_view(de->d_name) == "..")) {