mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 15:27:54 +00:00
Merge pull request #11105 from Chocobo1/activity
Handle invalid time activity properly
This commit is contained in:
commit
62a2374f49
@ -1136,6 +1136,8 @@ qlonglong TorrentHandle::timeSinceUpload() const
|
||||
#if (LIBTORRENT_VERSION_NUM < 10200)
|
||||
return m_nativeStatus.time_since_upload;
|
||||
#else
|
||||
if (m_nativeStatus.last_upload.time_since_epoch().count() == 0)
|
||||
return -1;
|
||||
return lt::total_seconds(lt::clock_type::now() - m_nativeStatus.last_upload);
|
||||
#endif
|
||||
}
|
||||
@ -1145,6 +1147,8 @@ qlonglong TorrentHandle::timeSinceDownload() const
|
||||
#if (LIBTORRENT_VERSION_NUM < 10200)
|
||||
return m_nativeStatus.time_since_download;
|
||||
#else
|
||||
if (m_nativeStatus.last_download.time_since_epoch().count() == 0)
|
||||
return -1;
|
||||
return lt::total_seconds(lt::clock_type::now() - m_nativeStatus.last_download);
|
||||
#endif
|
||||
}
|
||||
|
@ -136,9 +136,9 @@ QVariantMap serialize(const BitTorrent::TorrentHandle &torrent)
|
||||
ret[KEY_TORRENT_LAST_ACTIVITY_TIME] = 0;
|
||||
}
|
||||
else {
|
||||
QDateTime dt = QDateTime::currentDateTime();
|
||||
dt = dt.addSecs(-torrent.timeSinceActivity());
|
||||
ret[KEY_TORRENT_LAST_ACTIVITY_TIME] = dt.toSecsSinceEpoch();
|
||||
const qint64 dt = (QDateTime::currentDateTime().toSecsSinceEpoch()
|
||||
- torrent.timeSinceActivity());
|
||||
ret[KEY_TORRENT_LAST_ACTIVITY_TIME] = dt;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
Loading…
Reference in New Issue
Block a user