Skip to content

Commit

Permalink
Merge branch 'qbittorrent:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
qBittUser authored Dec 15, 2024
2 parents 35cc761 + eb2eea8 commit 1a1c1d0
Show file tree
Hide file tree
Showing 9 changed files with 180 additions and 195 deletions.
12 changes: 9 additions & 3 deletions src/base/bittorrent/sessionimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonValue>
#include <QMutexLocker>
#include <QNetworkAddressEntry>
#include <QNetworkInterface>
#include <QRegularExpression>
Expand Down Expand Up @@ -6234,6 +6235,8 @@ void SessionImpl::handleTrackerAlert(const lt::tracker_alert *alert)
if (!torrent)
return;

[[maybe_unused]] const QMutexLocker updatedTrackerStatusesLocker {&m_updatedTrackerStatusesMutex};

const auto prevSize = m_updatedTrackerStatuses.size();
QMap<int, int> &updateInfo = m_updatedTrackerStatuses[torrent->nativeHandle()][std::string(alert->tracker_url())][alert->local_endpoint];
if (prevSize < m_updatedTrackerStatuses.size())
Expand Down Expand Up @@ -6330,14 +6333,17 @@ void SessionImpl::updateTrackerEntryStatuses(lt::torrent_handle torrentHandle)
try
{
std::vector<lt::announce_entry> nativeTrackers = torrentHandle.trackers();
invoke([this, torrentHandle, nativeTrackers = std::move(nativeTrackers)]

QMutexLocker updatedTrackerStatusesLocker {&m_updatedTrackerStatusesMutex};
QHash<std::string, QHash<lt::tcp::endpoint, QMap<int, int>>> updatedTrackers = m_updatedTrackerStatuses.take(torrentHandle);
updatedTrackerStatusesLocker.unlock();

invoke([this, torrentHandle, nativeTrackers = std::move(nativeTrackers), updatedTrackers = std::move(updatedTrackers)]
{
TorrentImpl *torrent = m_torrents.value(torrentHandle.info_hash());
if (!torrent || torrent->isStopped())
return;

QHash<std::string, QHash<lt::tcp::endpoint, QMap<int, int>>> updatedTrackers = m_updatedTrackerStatuses.take(torrentHandle);

QHash<QString, TrackerEntryStatus> trackers;
trackers.reserve(updatedTrackers.size());
for (const lt::announce_entry &announceEntry : nativeTrackers)
Expand Down
2 changes: 2 additions & 0 deletions src/base/bittorrent/sessionimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include <QHash>
#include <QList>
#include <QMap>
#include <QMutex>
#include <QPointer>
#include <QSet>
#include <QThreadPool>
Expand Down Expand Up @@ -799,6 +800,7 @@ namespace BitTorrent
// This field holds amounts of peers reported by trackers in their responses to announces
// (torrent.tracker_name.tracker_local_endpoint.protocol_version.num_peers)
QHash<lt::torrent_handle, QHash<std::string, QHash<lt::tcp::endpoint, QMap<int, int>>>> m_updatedTrackerStatuses;
QMutex m_updatedTrackerStatusesMutex;

// I/O errored torrents
QSet<TorrentID> m_recentErroredTorrents;
Expand Down
4 changes: 2 additions & 2 deletions src/webui/www/private/rename_files.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
// Inject checkbox into the first column of the table header
const tableHeaders = $$("#bulkRenameFilesTableFixedHeaderDiv .dynamicTableHeader th");
if (tableHeaders.length > 0) {
const checkboxHeader = new Element("input");
const checkboxHeader = document.createElement("input");
checkboxHeader.type = "checkbox";
checkboxHeader.id = "rootMultiRename_cb";
checkboxHeader.addEventListener("click", (e) => {
Expand All @@ -56,7 +56,7 @@
});

const checkboxTH = tableHeaders[0];
checkboxHeader.injectInside(checkboxTH);
checkboxTH.append(checkboxHeader);
}

// Register keyboard events to modal window
Expand Down
2 changes: 1 addition & 1 deletion src/webui/www/private/scripts/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ window.qBittorrent.Download ??= (() => {
continue;

const category = data[i];
const option = new Element("option");
const option = document.createElement("option");
option.value = category.name;
option.textContent = category.name;
$("categorySelect").appendChild(option);
Expand Down
Loading

0 comments on commit 1a1c1d0

Please sign in to comment.