mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-01 04:32:01 +08:00
enlarge index_db with indicies in vendor
This commit is contained in:
parent
97d82a0d57
commit
5bb95e8a3e
@ -238,9 +238,11 @@ Index::const_iterator Index::recommended() const
|
|||||||
std::vector<Index> Index::load_db()
|
std::vector<Index> Index::load_db()
|
||||||
{
|
{
|
||||||
boost::filesystem::path cache_dir = boost::filesystem::path(Slic3r::data_dir()) / "cache";
|
boost::filesystem::path cache_dir = boost::filesystem::path(Slic3r::data_dir()) / "cache";
|
||||||
|
boost::filesystem::path vendor_dir = boost::filesystem::path(Slic3r::data_dir()) / "vendor";
|
||||||
|
|
||||||
std::vector<Index> index_db;
|
std::vector<Index> index_db;
|
||||||
std::string errors_cummulative;
|
std::string errors_cummulative;
|
||||||
|
|
||||||
for (auto &dir_entry : boost::filesystem::directory_iterator(cache_dir))
|
for (auto &dir_entry : boost::filesystem::directory_iterator(cache_dir))
|
||||||
if (Slic3r::is_idx_file(dir_entry)) {
|
if (Slic3r::is_idx_file(dir_entry)) {
|
||||||
Index idx;
|
Index idx;
|
||||||
@ -254,6 +256,20 @@ std::vector<Index> Index::load_db()
|
|||||||
index_db.emplace_back(std::move(idx));
|
index_db.emplace_back(std::move(idx));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto &dir_entry : boost::filesystem::directory_iterator(vendor_dir))
|
||||||
|
if (Slic3r::is_idx_file(dir_entry)) {
|
||||||
|
Index idx;
|
||||||
|
try {
|
||||||
|
idx.load(dir_entry.path());
|
||||||
|
} catch (const std::runtime_error &err) {
|
||||||
|
errors_cummulative += err.what();
|
||||||
|
errors_cummulative += "\n";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (std::find_if(index_db.begin(), index_db.end(), [idx](const Index& index) { return idx.vendor() == index.vendor();}) == index_db.end())
|
||||||
|
index_db.emplace_back(std::move(idx));
|
||||||
|
}
|
||||||
|
|
||||||
if (! errors_cummulative.empty())
|
if (! errors_cummulative.empty())
|
||||||
throw Slic3r::RuntimeError(errors_cummulative);
|
throw Slic3r::RuntimeError(errors_cummulative);
|
||||||
return index_db;
|
return index_db;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user