Skip to content

Commit

Permalink
Logging the extracted tags #355
Browse files Browse the repository at this point in the history
  • Loading branch information
mikekazakov committed Sep 22, 2024
1 parent e5420a2 commit cc26bd7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
12 changes: 12 additions & 0 deletions Source/Utility/include/Utility/Tags.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <filesystem>
#include <optional>
#include <utility>
#include <fmt/format.h>

namespace nc::utility {

Expand Down Expand Up @@ -106,6 +107,17 @@ class Tags::Tag

} // namespace nc::utility

template <>
struct fmt::formatter<nc::utility::Tags::Tag> : fmt::formatter<std::string> {
constexpr auto parse(fmt::format_parse_context &ctx) const { return ctx.begin(); }

template <typename FormatContext>
auto format(const nc::utility::Tags::Tag &_tag, FormatContext &_ctx) const
{
return fmt::format_to(_ctx.out(), "{} ({})", _tag.Label(), std::to_underlying(_tag.Color()));
}
};

namespace std {

template <>
Expand Down
8 changes: 6 additions & 2 deletions Source/VFS/source/Native/Host.mm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "DisplayNamesCache.h"
#include "File.h"
#include <VFS/VFSError.h>
#include <VFS/Log.h>
#include "../ListingInput.h"
#include "Fetching.h"
#include <Base/DispatchGroup.h>
Expand Down Expand Up @@ -225,13 +226,16 @@
// there's no point trying

// TODO: is it worth routing the I/O here? guess not atm
const int entry_fd = openat(fd, listing_source.filenames[n].c_str(), O_RDONLY | O_NONBLOCK);
const std::string &filename = listing_source.filenames[n];
const int entry_fd = openat(fd, filename.c_str(), O_RDONLY | O_NONBLOCK);
if( entry_fd < 0 )
continue; // guess silenty skipping the errors is ok here...
auto close_entry_fd = at_scope_end([entry_fd] { close(entry_fd); });

if( auto tags = utility::Tags::ReadTags(entry_fd); !tags.empty() )
if( auto tags = utility::Tags::ReadTags(entry_fd); !tags.empty() ) {
Log::Debug("Extracted the tags of the file '{}': {}", filename, fmt::join(tags, ", "));
listing_source.tags.emplace(n, std::move(tags));
}
}
}

Expand Down

0 comments on commit cc26bd7

Please sign in to comment.