mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-08 11:59:48 -04:00
fix(mkdwarfs): filter rules did not work correctly when input is root dir
This commit is contained in:
parent
c1da30db6b
commit
125121b7ca
@ -190,6 +190,10 @@ void builtin_script_<LoggerPolicy>::set_root_path(
|
||||
std::filesystem::path const& path) {
|
||||
// TODO: this whole thing needs to be windowsized
|
||||
root_path_ = u8string_to_string(path.u8string());
|
||||
|
||||
if (root_path_ == "/") {
|
||||
root_path_.clear();
|
||||
}
|
||||
}
|
||||
|
||||
template <typename LoggerPolicy>
|
||||
@ -252,7 +256,8 @@ bool builtin_script_<LoggerPolicy>::filter(entry_interface const& ei) {
|
||||
|
||||
for (const auto& r : filter_) {
|
||||
if (std::regex_match(r.floating ? path : relpath, r.re)) {
|
||||
LOG_TRACE << path << " matched rule '" << r.rule << "'";
|
||||
LOG_TRACE << "[" << path << "] / [" << relpath << "] matched rule '"
|
||||
<< r.rule << "'";
|
||||
switch (r.type) {
|
||||
case filter_rule::rule_type::include:
|
||||
return true;
|
||||
@ -263,7 +268,7 @@ bool builtin_script_<LoggerPolicy>::filter(entry_interface const& ei) {
|
||||
}
|
||||
}
|
||||
|
||||
LOG_TRACE << path << " matched no rule";
|
||||
LOG_TRACE << "[" << path << "] / [" << relpath << "] matched no rule";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1591,6 +1591,19 @@ TEST(mkdwarfs_test, filter_recursion) {
|
||||
"recursion detected while opening file: filt1.txt"));
|
||||
}
|
||||
|
||||
TEST(mkdwarfs_test, filter_root_dir) {
|
||||
auto t = mkdwarfs_tester::create_empty();
|
||||
t.add_test_file_tree();
|
||||
EXPECT_EQ(0, t.run({"-i", "/", "-o", "-", "-F", "- /var/", "-F", "- /usr/"}))
|
||||
<< t.err();
|
||||
auto fs = t.fs_from_stdout();
|
||||
EXPECT_TRUE(fs.find("/"));
|
||||
EXPECT_FALSE(fs.find("/var"));
|
||||
EXPECT_FALSE(fs.find("/usr"));
|
||||
EXPECT_TRUE(fs.find("/dev"));
|
||||
EXPECT_TRUE(fs.find("/etc"));
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr std::array<std::string_view, 9> const pack_mode_names = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user