Skip to content

Commit

Permalink
Deduplicate automation autoload path
Browse files Browse the repository at this point in the history
Fixes #168
Fixes arch1t3cht#15
  • Loading branch information
arch1t3cht committed Dec 3, 2023
1 parent d9223d1 commit 78f2dc6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/auto4_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,14 @@ namespace Automation4 {

std::vector<std::future<std::unique_ptr<Script>>> script_futures;

std::set<std::filesystem::path> dirnames;
for (auto tok : agi::Split(path, '|')) {
auto dirname = config::path->Decode(std::string(tok));
if (!agi::fs::DirectoryExists(dirname)) continue;

if (dirnames.count(dirname)) continue;
dirnames.insert(dirname);

for (auto filename : agi::fs::DirectoryIterator(dirname, "*.*"))
script_futures.emplace_back(std::async(std::launch::async, [=] {
return ScriptFactory::CreateFromFile(dirname/filename, false, false);
Expand Down

0 comments on commit 78f2dc6

Please # to comment.