Improve free disk space checking for WebAPI

Use single free disk space checker instance for all the web sessions.

PR #19855.
Closes #19732.
This commit is contained in:
Vladimir Golovnev
2023-11-07 12:44:27 +03:00
committed by GitHub
parent 30d9978c97
commit c88bd7cb3f
7 changed files with 73 additions and 61 deletions

View File

@@ -28,22 +28,17 @@
#pragma once
#include <QElapsedTimer>
#include <QVariantMap>
#include <QSet>
#include <QVariantMap>
#include "base/bittorrent/infohash.h"
#include "apicontroller.h"
class QThread;
namespace BitTorrent
{
class Torrent;
}
class FreeDiskSpaceChecker;
class SyncController : public APIController
{
Q_OBJECT
@@ -54,14 +49,14 @@ public:
explicit SyncController(IApplication *app, QObject *parent = nullptr);
public slots:
void updateFreeDiskSpace(qint64 freeDiskSpace);
private slots:
void maindataAction();
void torrentPeersAction();
private:
qint64 getFreeDiskSpace();
void invokeChecker();
void makeMaindataSnapshot();
QJsonObject generateMaindataSyncData(int id, bool fullUpdate);
@@ -85,8 +80,6 @@ private:
void onTorrentTrackersChanged(BitTorrent::Torrent *torrent);
qint64 m_freeDiskSpace = 0;
QElapsedTimer m_freeDiskSpaceElapsedTimer;
bool m_isFreeDiskSpaceCheckerRunning = false;
QVariantMap m_lastPeersResponse;
QVariantMap m_lastAcceptedPeersResponse;