* @brief Fetches manifest.json from each configured repository and merges * the results into the extension catalog. */
| 384 | * the results into the extension catalog. |
| 385 | */ |
| 386 | void Misc::ExtensionManager::refreshRepositories() |
| 387 | { |
| 388 | if (m_loading) |
| 389 | return; |
| 390 | |
| 391 | for (auto* reply : std::as_const(m_activeReplies)) { |
| 392 | if (reply) { |
| 393 | reply->disconnect(this); |
| 394 | reply->abort(); |
| 395 | reply->deleteLater(); |
| 396 | } |
| 397 | } |
| 398 | |
| 399 | m_activeReplies.clear(); |
| 400 | |
| 401 | m_allExtensions = QJsonArray(); |
| 402 | m_filteredExtensions.clear(); |
| 403 | m_selectedIndex = -1; |
| 404 | m_pendingManifests = 0; |
| 405 | m_pendingExtensionMetas = 0; |
| 406 | Q_EMIT selectedIndexChanged(); |
| 407 | Q_EMIT filteredExtensionsChanged(); |
| 408 | |
| 409 | QStringList remoteRepos; |
| 410 | QStringList localRepos; |
| 411 | for (const auto& repo : std::as_const(m_repositories)) |
| 412 | if (isLocalRepo(repo)) |
| 413 | localRepos.append(repo); |
| 414 | else |
| 415 | remoteRepos.append(repo); |
| 416 | |
| 417 | for (const auto& localPath : std::as_const(localRepos)) |
| 418 | loadLocalManifest(localPath); |
| 419 | |
| 420 | m_pendingManifests = remoteRepos.count(); |
| 421 | if (m_pendingManifests > 0) { |
| 422 | m_loading = true; |
| 423 | Q_EMIT loadingChanged(); |
| 424 | |
| 425 | for (const auto& repoUrl : std::as_const(remoteRepos)) { |
| 426 | auto* reply = m_nam.get(QNetworkRequest(QUrl(repoUrl))); |
| 427 | reply->setProperty("repoUrl", repoUrl); |
| 428 | m_activeReplies.insert(reply); |
| 429 | connect(reply, &QNetworkReply::finished, this, &ExtensionManager::onManifestReply); |
| 430 | } |
| 431 | } |
| 432 | |
| 433 | else { |
| 434 | applyFilter(); |
| 435 | rebuildInstalledPlugins(); |
| 436 | } |
| 437 | } |
| 438 | |
| 439 | /** |
| 440 | * @brief Adds a new repository URL and persists the list. |
no test coverage detected