Merge pull request #12035 from glassez/move-storage

Move torrent storages one by one
This commit is contained in:
Vladimir Golovnev 2020-03-13 15:59:05 +03:00 committed by GitHub
commit 5127156ba4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 217 additions and 166 deletions

View file

@ -96,6 +96,8 @@ namespace BitTorrent
class TrackerEntry;
struct CreateTorrentParams;
enum class MoveStorageMode;
// Using `Q_ENUM_NS()` without a wrapper namespace in our case is not advised
// since `Q_NAMESPACE` cannot be used when the same namespace resides at different files.
// https://www.kdab.com/new-qt-5-8-meta-object-support-namespaces/#comment-143779
@ -461,6 +463,8 @@ namespace BitTorrent
void handleTorrentTrackerWarning(TorrentHandle *const torrent, const QString &trackerUrl);
void handleTorrentTrackerError(TorrentHandle *const torrent, const QString &trackerUrl);
bool addMoveTorrentStorageJob(TorrentHandle *torrent, const QString &newPath, MoveStorageMode mode);
signals:
void addTorrentFailed(const QString &error);
void allTorrentsFinished();
@ -514,6 +518,13 @@ namespace BitTorrent
void networkConfigurationChange(const QNetworkConfiguration &);
private:
struct MoveStorageJob
{
TorrentHandle *torrent;
QString path;
MoveStorageMode mode;
};
struct RemovingTorrentData
{
QString name;
@ -583,6 +594,8 @@ namespace BitTorrent
#if (LIBTORRENT_VERSION_NUM >= 10200)
void handleAlertsDroppedAlert(const lt::alerts_dropped_alert *p) const;
#endif
void handleStorageMovedAlert(const lt::storage_moved_alert *p);
void handleStorageMovedFailedAlert(const lt::storage_moved_failed_alert *p);
void createTorrentHandle(const lt::torrent_handle &nativeHandle);
@ -592,6 +605,9 @@ namespace BitTorrent
std::vector<lt::alert *> getPendingAlerts(lt::time_duration time = lt::time_duration::zero()) const;
void moveTorrentStorage(const MoveStorageJob &job) const;
void handleMoveTorrentStorageJobFinished(const QString &errorMessage = {});
// BitTorrent
lt::session *m_nativeSession = nullptr;
@ -732,6 +748,8 @@ namespace BitTorrent
QNetworkConfigurationManager *m_networkManager = nullptr;
QList<MoveStorageJob> m_moveStorageQueue;
static Session *m_instance;
};
}