Improve torrent loading code

This commit is contained in:
Vladimir Golovnev (Glassez)
2020-08-05 08:31:41 +03:00
parent eb99bfe20f
commit dc3d23c045
11 changed files with 361 additions and 356 deletions

View File

@@ -31,6 +31,7 @@
#include <functional>
#include <libtorrent/add_torrent_params.hpp>
#include <libtorrent/fwd.hpp>
#include <libtorrent/torrent_handle.hpp>
#include <libtorrent/torrent_status.hpp>
@@ -53,35 +54,26 @@ namespace BitTorrent
class Session;
struct AddTorrentParams;
struct CreateTorrentParams
struct LoadTorrentParams
{
CreateTorrentParams() = default;
explicit CreateTorrentParams(const AddTorrentParams &params);
lt::add_torrent_params ltAddTorrentParams {};
// for both new and restored torrents
QString name;
QString category;
QSet<QString> tags;
QString savePath;
int uploadLimit = -1;
int downloadLimit = -1;
bool disableTempPath = false;
bool sequential = false;
bool firstLastPiecePriority = false;
bool hasSeedStatus = false;
bool skipChecking = false;
bool hasRootFolder = true;
bool forced = false;
bool paused = false;
bool restored = false; // is existing torrent job?
// for new torrents
QVector<DownloadPriority> filePriorities;
QDateTime addedTime;
// for restored torrents
qreal ratioLimit = TorrentHandle::USE_GLOBAL_RATIO;
int seedingTimeLimit = TorrentHandle::USE_GLOBAL_SEEDING_TIME;
bool restored = false; // is existing torrent job?
};
enum class MoveStorageMode
@@ -97,7 +89,7 @@ namespace BitTorrent
public:
TorrentHandleImpl(Session *session, const lt::torrent_handle &nativeHandle,
const CreateTorrentParams &params);
const LoadTorrentParams &params);
~TorrentHandleImpl() override;
bool isValid() const;
@@ -329,5 +321,7 @@ namespace BitTorrent
bool m_useAutoTMM;
bool m_unchecked = false;
lt::add_torrent_params m_ltAddTorrentParams;
};
}