refactor: make tr_torrent::any_date_ private (#6148)

This commit is contained in:
Charles Kerr 2023-10-21 22:23:08 -05:00 committed by GitHub
parent 8f7330523c
commit 682e4f2c2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 12 deletions

View File

@ -133,7 +133,7 @@ auto getTorrents(tr_session* session, tr_variant* args)
std::begin(session->torrents()),
std::end(session->torrents()),
std::back_inserter(torrents),
[&cutoff](auto const* tor) { return tor->anyDate >= cutoff; });
[&cutoff](auto const* tor) { return tor->has_changed_since(cutoff); });
}
else
{

View File

@ -1021,9 +1021,9 @@ void tr_torrent::init(tr_ctor const* const ctor)
TR_ASSERT(downloadedCur == 0);
TR_ASSERT(uploadedCur == 0);
auto const now = tr_time();
addedDate = now; // this is a default that will be overwritten by the resume file
anyDate = now;
mark_changed();
addedDate = tr_time(); // this is a default that will be overwritten by the resume file
tr_resume::fields_t loaded = {};
@ -2620,7 +2620,7 @@ void tr_torrent::mark_edited()
void tr_torrent::mark_changed()
{
this->anyDate = tr_time();
this->bump_date_changed(tr_time());
}
void tr_torrent::set_blocks(tr_bitfield blocks)

View File

@ -621,14 +621,11 @@ public:
unique_id_ = id;
}
constexpr void set_date_active(time_t t) noexcept
constexpr void set_date_active(time_t when) noexcept
{
this->activityDate = t;
this->activityDate = when;
if (this->anyDate < t)
{
this->anyDate = t;
}
bump_date_changed(when);
}
[[nodiscard]] constexpr auto activity() const noexcept
@ -705,6 +702,11 @@ public:
void mark_edited();
void mark_changed();
[[nodiscard]] constexpr auto has_changed_since(time_t when) const noexcept
{
return changed_date_ > when;
}
void set_bandwidth_group(std::string_view group_name) noexcept;
[[nodiscard]] constexpr auto get_priority() const noexcept
@ -966,7 +968,6 @@ public:
time_t activityDate = 0;
time_t addedDate = 0;
time_t anyDate = 0;
time_t doneDate = 0;
time_t editDate = 0;
time_t startDate = 0;
@ -1149,6 +1150,14 @@ private:
}
}
constexpr void bump_date_changed(time_t when)
{
if (changed_date_ < when)
{
changed_date_ = when;
}
}
void set_verify_state(VerifyState state);
void on_metainfo_updated();
@ -1175,6 +1184,8 @@ private:
*/
tr_peer_id_t peer_id_ = tr_peerIdInit();
time_t changed_date_ = 0;
float verify_progress_ = -1.0F;
float seed_ratio_ = 0.0F;