diff --git a/gtk/Torrent.cc b/gtk/Torrent.cc index 67f547160..2f6ac4dc5 100644 --- a/gtk/Torrent.cc +++ b/gtk/Torrent.cc @@ -241,8 +241,9 @@ Torrent::ChangeFlags Torrent::Impl::update_cache() auto seed_ratio = 0.0; auto const has_seed_ratio = tr_torrentGetSeedRatio(raw_torrent_, &seed_ratio); + auto const view = tr_torrentView(raw_torrent_); - update_cache_value(cache_.name, tr_torrentName(raw_torrent_), result, ChangeFlag::NAME); + update_cache_value(cache_.name, view.name, result, ChangeFlag::NAME); update_cache_value(cache_.speed_up, stats->pieceUploadSpeed_KBps, 0.01F, result, ChangeFlag::SPEED_UP); update_cache_value(cache_.speed_down, stats->pieceDownloadSpeed_KBps, 0.01F, result, ChangeFlag::SPEED_DOWN); update_cache_value(cache_.active_peers_up, stats->peersGettingFromUs, result, ChangeFlag::ACTIVE_PEERS_UP); @@ -290,7 +291,7 @@ Torrent::ChangeFlags Torrent::Impl::update_cache() Percents(stats->seedRatioPercentDone), result, ChangeFlag::SEED_RATIO_PERCENT_DONE); - update_cache_value(cache_.total_size, tr_torrentTotalSize(raw_torrent_), result, ChangeFlag::TOTAL_SIZE); + update_cache_value(cache_.total_size, view.total_size, result, ChangeFlag::TOTAL_SIZE); update_cache_value(cache_.has_seed_ratio, has_seed_ratio, result, ChangeFlag::LONG_PROGRESS); update_cache_value(cache_.have_unchecked, stats->haveUnchecked, result, ChangeFlag::LONG_PROGRESS); @@ -313,7 +314,7 @@ Torrent::ChangeFlags Torrent::Impl::update_cache() if (result.test(ChangeFlag::NAME)) { - cache_.name_collated = fmt::format("{}\t{}", cache_.name.lowercase(), tr_torrentView(raw_torrent_).hash_string); + cache_.name_collated = fmt::format("{}\t{}", cache_.name.lowercase(), view.hash_string); } return result; diff --git a/libtransmission/resume.cc b/libtransmission/resume.cc index bc5a2c86c..9cab0a44b 100644 --- a/libtransmission/resume.cc +++ b/libtransmission/resume.cc @@ -346,7 +346,7 @@ auto loadIdleLimits(tr_variant* dict, tr_torrent* tor) void saveName(tr_variant* dict, tr_torrent const* tor) { - tr_variantDictAddStrView(dict, TR_KEY_name, tr_torrentName(tor)); + tr_variantDictAddStrView(dict, TR_KEY_name, tor->name()); } auto loadName(tr_variant* dict, tr_torrent* tor) diff --git a/libtransmission/torrent.cc b/libtransmission/torrent.cc index df30271d4..40a57d106 100644 --- a/libtransmission/torrent.cc +++ b/libtransmission/torrent.cc @@ -98,13 +98,6 @@ char const* tr_torrentName(tr_torrent const* tor) return tor != nullptr ? tor->name().c_str() : ""; } -uint64_t tr_torrentTotalSize(tr_torrent const* tor) -{ - TR_ASSERT(tr_isTorrent(tor)); - - return tor->total_size(); -} - tr_torrent_id_t tr_torrentId(tr_torrent const* tor) { return tor != nullptr ? tor->id() : -1; @@ -406,7 +399,7 @@ void torrentCallScript(tr_torrent const* tor, std::string const& script) { "TR_TORRENT_HASH"sv, tor->info_hash_string() }, { "TR_TORRENT_ID"sv, id_str }, { "TR_TORRENT_LABELS"sv, labels_str }, - { "TR_TORRENT_NAME"sv, tr_torrentName(tor) }, + { "TR_TORRENT_NAME"sv, tor->name() }, { "TR_TORRENT_TRACKERS"sv, trackers_str }, }; @@ -1528,7 +1521,7 @@ tr_torrent_view tr_torrentView(tr_torrent const* tor) TR_ASSERT(tr_isTorrent(tor)); auto ret = tr_torrent_view{}; - ret.name = tr_torrentName(tor); + ret.name = tor->name().c_str(); ret.hash_string = tor->info_hash_string().c_str(); ret.comment = tor->comment().c_str(); ret.creator = tor->creator().c_str(); diff --git a/libtransmission/transmission.h b/libtransmission/transmission.h index a17de0785..cbaaac857 100644 --- a/libtransmission/transmission.h +++ b/libtransmission/transmission.h @@ -952,8 +952,6 @@ bool tr_torrentSetMetainfoFromFile(tr_torrent* torrent, tr_torrent_metainfo cons */ char const* tr_torrentName(tr_torrent const* tor); -uint64_t tr_torrentTotalSize(tr_torrent const* tor); - /** * @brief find the location of a torrent's file by looking with and without * the ".part" suffix, looking in downloadDir and incompleteDir, etc. @@ -1447,9 +1445,9 @@ struct tr_stat char const* errorString; /** Byte count of all the piece data we'll have downloaded when we're done, - whether or not we have it yet. This may be less than `tr_torrentTotalSize()` - if only some of the torrent's files are wanted. - [0...tr_torrentTotalSize()] */ + whether or not we have it yet. If we only want some of the files, + this may be less than `tr_torrent_view.total_size`. + [0...tr_torrent_view.total_size] */ uint64_t sizeWhenDone; /** Byte count of how much data is left to be downloaded until we've got diff --git a/macosx/Torrent.mm b/macosx/Torrent.mm index 04616ab32..81291c625 100644 --- a/macosx/Torrent.mm +++ b/macosx/Torrent.mm @@ -612,7 +612,7 @@ bool trashDataFile(char const* filename, void* /*user_data*/, tr_error** error) - (uint64_t)size { - return tr_torrentTotalSize(self.fHandle); + return tr_torrentView(self.fHandle).total_size; } - (uint64_t)sizeLeft