mirror of
https://github.com/tstack/lnav.git
synced 2024-09-11 13:05:51 +03:00
[unique_path] fix an infinite loop when files rolled
This commit is contained in:
parent
af36896f50
commit
809159140c
@ -114,7 +114,11 @@ public:
|
||||
for (auto &src : pair.second) {
|
||||
auto &path = src->get_path_prefix();
|
||||
|
||||
src->set_path_prefix(path.parent_path());
|
||||
if (path.empty()) {
|
||||
all_common = false;
|
||||
} else {
|
||||
src->set_path_prefix(path.parent_path());
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (all_common);
|
||||
@ -137,9 +141,17 @@ public:
|
||||
} else {
|
||||
src->set_unique_path(prefix.filename() + "/" + unique_path);
|
||||
}
|
||||
src->set_path_prefix(prefix.parent_path());
|
||||
|
||||
this->upg_unique_paths[src->get_unique_path()].push_back(src);
|
||||
filesystem::path parent = prefix.parent_path();
|
||||
|
||||
src->set_path_prefix(parent);
|
||||
|
||||
if (!parent.empty()) {
|
||||
this->upg_unique_paths[src->get_unique_path()].push_back(
|
||||
src);
|
||||
} else {
|
||||
src->set_unique_path("[" + src->get_unique_path());
|
||||
}
|
||||
}
|
||||
|
||||
loop_count += 1;
|
||||
|
@ -73,6 +73,7 @@ TEST_CASE("unique_path") {
|
||||
unique_path_generator upg;
|
||||
|
||||
auto bar = make_shared<my_path_source>("/foo/bar");
|
||||
auto bar_dupe = make_shared<my_path_source>("/foo/bar");
|
||||
auto baz = make_shared<my_path_source>("/foo/baz");
|
||||
auto baz2 = make_shared<my_path_source>("/foo2/bar");
|
||||
auto log1 = make_shared<my_path_source>(
|
||||
@ -81,6 +82,7 @@ TEST_CASE("unique_path") {
|
||||
"/home/bob/downloads/machine2/var/log/syslog.log");
|
||||
|
||||
upg.add_source(bar);
|
||||
upg.add_source(bar_dupe);
|
||||
upg.add_source(baz);
|
||||
upg.add_source(baz2);
|
||||
upg.add_source(log1);
|
||||
@ -89,6 +91,7 @@ TEST_CASE("unique_path") {
|
||||
upg.generate();
|
||||
|
||||
CHECK(bar->get_unique_path() == "[foo]/bar");
|
||||
CHECK(bar_dupe->get_unique_path() == "[foo]/bar");
|
||||
CHECK(baz->get_unique_path() == "baz");
|
||||
CHECK(baz2->get_unique_path() == "[foo2]/bar");
|
||||
CHECK(log1->get_unique_path() == "[machine1]/syslog.log");
|
||||
|
Loading…
Reference in New Issue
Block a user