mirror of
https://github.com/transmission/transmission
synced 2024-12-23 00:04:06 +00:00
This commit is contained in:
parent
e407bcc501
commit
693d202a64
3 changed files with 4 additions and 19 deletions
|
@ -1323,7 +1323,7 @@ void tr_session::closeImplPart2(std::promise<void>* closed_promise, std::chrono:
|
|||
this->announcer_.reset();
|
||||
this->announcer_udp_.reset();
|
||||
|
||||
stats().saveIfDirty();
|
||||
stats().save();
|
||||
peer_mgr_.reset();
|
||||
openFiles().closeAll();
|
||||
tr_utpClose(this);
|
||||
|
@ -2169,7 +2169,7 @@ tr_session::tr_session(std::string_view config_dir, tr_variant* settings_dict)
|
|||
tr_torrentSave(tor);
|
||||
}
|
||||
|
||||
stats().saveIfDirty();
|
||||
stats().save();
|
||||
});
|
||||
save_timer_->startRepeating(SaveIntervalSecs);
|
||||
|
||||
|
|
|
@ -82,7 +82,6 @@ void tr_stats::save() const
|
|||
void tr_stats::clear()
|
||||
{
|
||||
single_ = old_ = Zero;
|
||||
is_dirty_ = true;
|
||||
start_time_ = tr_time();
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ public:
|
|||
|
||||
~tr_stats()
|
||||
{
|
||||
saveIfDirty();
|
||||
save();
|
||||
}
|
||||
|
||||
void clear();
|
||||
|
@ -45,35 +45,23 @@ public:
|
|||
constexpr void addUploaded(uint32_t n_bytes) noexcept
|
||||
{
|
||||
single_.uploadedBytes += n_bytes;
|
||||
is_dirty_ = true;
|
||||
}
|
||||
|
||||
constexpr void addDownloaded(uint32_t n_bytes) noexcept
|
||||
{
|
||||
single_.downloadedBytes += n_bytes;
|
||||
is_dirty_ = true;
|
||||
}
|
||||
|
||||
constexpr void addFileCreated() noexcept
|
||||
{
|
||||
++single_.filesAdded;
|
||||
is_dirty_ = true;
|
||||
}
|
||||
|
||||
void saveIfDirty()
|
||||
{
|
||||
if (is_dirty_)
|
||||
{
|
||||
save();
|
||||
is_dirty_ = false;
|
||||
}
|
||||
}
|
||||
void save() const;
|
||||
|
||||
private:
|
||||
static tr_session_stats add(tr_session_stats const& a, tr_session_stats const& b);
|
||||
|
||||
void save() const;
|
||||
|
||||
static tr_session_stats loadOldStats(std::string_view config_dir);
|
||||
|
||||
std::string const config_dir_;
|
||||
|
@ -82,6 +70,4 @@ private:
|
|||
static constexpr auto Zero = tr_session_stats{ TR_RATIO_NA, 0U, 0U, 0U, 0U, 0U };
|
||||
tr_session_stats single_ = Zero;
|
||||
tr_session_stats old_ = Zero;
|
||||
|
||||
bool is_dirty_ = false;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue