mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-10 04:50:31 -04:00
Perform metadata check
This commit is contained in:
parent
c2da034983
commit
6ddbcad93b
@ -87,6 +87,13 @@ class contextual_option {
|
|||||||
return default_ && pred(*default_);
|
return default_ && pred(*default_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void visit_contextual(T&& visitor) const {
|
||||||
|
for (auto const& [ctx, val] : contextual_) {
|
||||||
|
visitor(ctx, val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::optional<value_type> get_optional_impl(context_type const& ctx) const {
|
std::optional<value_type> get_optional_impl(context_type const& ctx) const {
|
||||||
if (auto it = contextual_.find(ctx); it != contextual_.end()) {
|
if (auto it = contextual_.find(ctx); it != contextual_.end()) {
|
||||||
|
@ -1022,6 +1022,16 @@ int mkdwarfs_main(int argc, sys_char** argv) {
|
|||||||
compressor_parser);
|
compressor_parser);
|
||||||
cop.parse(compression);
|
cop.parse(compression);
|
||||||
cop.dump(std::cerr);
|
cop.dump(std::cerr);
|
||||||
|
|
||||||
|
compression_opt.visit_contextual([catmgr = options.inode.categorizer_mgr](
|
||||||
|
auto cat, block_compressor const& bc) {
|
||||||
|
if (!bc.check_metadata(catmgr->category_metadata_sample(cat))) {
|
||||||
|
throw std::runtime_error(
|
||||||
|
fmt::format("compression '{}' cannot be used for category '{}': "
|
||||||
|
"insufficient metadata",
|
||||||
|
bc.describe(), catmgr->category_name(cat)));
|
||||||
|
}
|
||||||
|
});
|
||||||
} catch (std::exception const& e) {
|
} catch (std::exception const& e) {
|
||||||
LOG_ERROR << e.what();
|
LOG_ERROR << e.what();
|
||||||
return 1;
|
return 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user