Browse Source

Fix wrong "added on" date

This only happens for magnet links when its metadata has yet to be retrieved.
Closes #11124.
adaptive-webui-19844
Chocobo1 5 years ago
parent
commit
3a11c23efd
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 9
      src/base/bittorrent/session.cpp
  2. 3
      src/base/bittorrent/torrenthandle.cpp
  3. 2
      src/base/bittorrent/torrenthandle.h

9
src/base/bittorrent/session.cpp

@ -2028,6 +2028,11 @@ bool Session::addTorrent_impl(CreateTorrentParams params, const MagnetUri &magne @@ -2028,6 +2028,11 @@ bool Session::addTorrent_impl(CreateTorrentParams params, const MagnetUri &magne
p.upload_limit = params.uploadLimit;
p.download_limit = params.downloadLimit;
#if (LIBTORRENT_VERSION_NUM >= 10200)
if (params.addedTime.isValid())
p.added_time = params.addedTime.toSecsSinceEpoch();
#endif
// Preallocation mode
p.storage_mode = isPreallocationEnabled()
? lt::storage_mode_allocate : lt::storage_mode_sparse;
@ -4464,6 +4469,10 @@ namespace @@ -4464,6 +4469,10 @@ namespace
torrentParams.firstLastPiecePriority = fast.dict_find_int_value("qBt-firstLastPiecePriority");
torrentParams.sequential = fast.dict_find_int_value("qBt-sequential");
const lt::bdecode_node addedTimeNode = fast.dict_find("qBt-addedTime");
if (addedTimeNode.type() == lt::bdecode_node::int_t)
torrentParams.addedTime = QDateTime::fromSecsSinceEpoch(addedTimeNode.int_value());
queuePos = fast.dict_find_int_value("qBt-queuePosition");
return true;

3
src/base/bittorrent/torrenthandle.cpp

@ -50,7 +50,6 @@ @@ -50,7 +50,6 @@
#endif
#include <QBitArray>
#include <QDateTime>
#include <QDebug>
#include <QDir>
#include <QFile>
@ -1775,6 +1774,8 @@ void TorrentHandle::handleSaveResumeDataAlert(const lt::save_resume_data_alert * @@ -1775,6 +1774,8 @@ void TorrentHandle::handleSaveResumeDataAlert(const lt::save_resume_data_alert *
// restored if qBittorrent quits before the metadata are retrieved:
resumeData["qBt-firstLastPiecePriority"] = hasFirstLastPiecePriority();
resumeData["qBt-sequential"] = isSequentialDownload();
resumeData["qBt-addedTime"] = addedTime().toSecsSinceEpoch();
}
else {
const auto savePath = resumeData.find_key("save_path")->string();

2
src/base/bittorrent/torrenthandle.h

@ -36,6 +36,7 @@ @@ -36,6 +36,7 @@
#include <libtorrent/torrent_handle.hpp>
#include <libtorrent/torrent_status.hpp>
#include <QDateTime>
#include <QHash>
#include <QObject>
#include <QQueue>
@ -83,6 +84,7 @@ namespace BitTorrent @@ -83,6 +84,7 @@ namespace BitTorrent
int downloadLimit;
// for new torrents
QVector<DownloadPriority> filePriorities;
QDateTime addedTime;
// for restored torrents
qreal ratioLimit;
int seedingTimeLimit;

Loading…
Cancel
Save