Browse Source

Merge pull request #11105 from Chocobo1/activity

Handle invalid time activity properly
adaptive-webui-19844
Mike Tzou 5 years ago committed by GitHub
parent
commit
62a2374f49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/base/bittorrent/torrenthandle.cpp
  2. 6
      src/webui/api/serialize/serialize_torrent.cpp

4
src/base/bittorrent/torrenthandle.cpp

@ -1136,6 +1136,8 @@ qlonglong TorrentHandle::timeSinceUpload() const
#if (LIBTORRENT_VERSION_NUM < 10200) #if (LIBTORRENT_VERSION_NUM < 10200)
return m_nativeStatus.time_since_upload; return m_nativeStatus.time_since_upload;
#else #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); return lt::total_seconds(lt::clock_type::now() - m_nativeStatus.last_upload);
#endif #endif
} }
@ -1145,6 +1147,8 @@ qlonglong TorrentHandle::timeSinceDownload() const
#if (LIBTORRENT_VERSION_NUM < 10200) #if (LIBTORRENT_VERSION_NUM < 10200)
return m_nativeStatus.time_since_download; return m_nativeStatus.time_since_download;
#else #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); return lt::total_seconds(lt::clock_type::now() - m_nativeStatus.last_download);
#endif #endif
} }

6
src/webui/api/serialize/serialize_torrent.cpp

@ -136,9 +136,9 @@ QVariantMap serialize(const BitTorrent::TorrentHandle &torrent)
ret[KEY_TORRENT_LAST_ACTIVITY_TIME] = 0; ret[KEY_TORRENT_LAST_ACTIVITY_TIME] = 0;
} }
else { else {
QDateTime dt = QDateTime::currentDateTime(); const qint64 dt = (QDateTime::currentDateTime().toSecsSinceEpoch()
dt = dt.addSecs(-torrent.timeSinceActivity()); - torrent.timeSinceActivity());
ret[KEY_TORRENT_LAST_ACTIVITY_TIME] = dt.toSecsSinceEpoch(); ret[KEY_TORRENT_LAST_ACTIVITY_TIME] = dt;
} }
return ret; return ret;

Loading…
Cancel
Save