| 388 | } |
| 389 | |
| 390 | void DirectoryRefresher::addMultipleModsFilesToStructure( |
| 391 | MOShared::DirectoryEntry* directoryStructure, const std::vector<EntryInfo>& entries, |
| 392 | DirectoryRefreshProgress* progress) |
| 393 | { |
| 394 | std::vector<DirectoryStats> stats(entries.size()); |
| 395 | |
| 396 | if (progress) { |
| 397 | progress->start(entries.size()); |
| 398 | } |
| 399 | |
| 400 | log::debug("refresher: using {} threads", m_threadCount); |
| 401 | g_threads.setMax(m_threadCount); |
| 402 | |
| 403 | for (std::size_t i = 0; i < entries.size(); ++i) { |
| 404 | const auto& e = entries[i]; |
| 405 | const int prio = e.priority + 1; |
| 406 | |
| 407 | if constexpr (DirectoryStats::EnableInstrumentation) { |
| 408 | stats[i].mod = entries[i].modName.toStdString(); |
| 409 | } |
| 410 | |
| 411 | try { |
| 412 | if (e.stealFiles.length() > 0) { |
| 413 | stealModFilesIntoStructure(directoryStructure, e.modName, prio, e.absolutePath, |
| 414 | e.stealFiles); |
| 415 | |
| 416 | if (progress) { |
| 417 | progress->addDone(); |
| 418 | } |
| 419 | } else { |
| 420 | auto& mt = g_threads.request(); |
| 421 | |
| 422 | mt.gameFeatures = &m_Core.gameFeatures(); |
| 423 | mt.progress = progress; |
| 424 | mt.ds = directoryStructure; |
| 425 | mt.modName = e.modName.toStdWString(); |
| 426 | mt.path = QDir::toNativeSeparators(e.absolutePath).toStdWString(); |
| 427 | mt.prio = prio; |
| 428 | |
| 429 | mt.archives.clear(); |
| 430 | for (auto&& a : e.archives) { |
| 431 | mt.archives.push_back(a.toStdWString()); |
| 432 | } |
| 433 | |
| 434 | mt.enabledArchives.clear(); |
| 435 | for (auto&& a : m_EnabledArchives) { |
| 436 | mt.enabledArchives.insert(a.toStdWString()); |
| 437 | } |
| 438 | |
| 439 | mt.stats = &stats[i]; |
| 440 | |
| 441 | mt.wakeup(); |
| 442 | } |
| 443 | } catch (const std::exception& ex) { |
| 444 | emit error(tr("failed to read mod (%1): %2").arg(e.modName, ex.what())); |
| 445 | } |
| 446 | } |
| 447 |
no test coverage detected