refactor: remove tr_sessionGetConfigDir() (#3506)
* refactor: remove tr_sessionGetConfigDir() from GTK client * refactor: remove tr_sessionGetConfigDir() from daemon * refactor: remove tr_sessionGetConfigDir() * refactor: remove tr_getTorrentDir() * fixup! refactor: remove tr_sessionGetConfigDir()
This commit is contained in:
parent
3f5b439fcc
commit
c50da43ae0
|
@ -672,8 +672,10 @@ struct daemon_data
|
|||
bool paused;
|
||||
};
|
||||
|
||||
static void daemon_reconfigure(void* /*arg*/)
|
||||
static void daemon_reconfigure(void* vdata)
|
||||
{
|
||||
auto const* const ddata = static_cast<daemon_data const*>(vdata);
|
||||
|
||||
if (mySession == nullptr)
|
||||
{
|
||||
tr_logAddInfo(_("Deferring reload until session is fully started."));
|
||||
|
@ -682,7 +684,6 @@ static void daemon_reconfigure(void* /*arg*/)
|
|||
else
|
||||
{
|
||||
tr_variant settings;
|
||||
char const* configDir;
|
||||
|
||||
/* reopen the logfile to allow for log rotation */
|
||||
if (logfileName != nullptr)
|
||||
|
@ -690,11 +691,10 @@ static void daemon_reconfigure(void* /*arg*/)
|
|||
reopen_log_file(logfileName);
|
||||
}
|
||||
|
||||
configDir = tr_sessionGetConfigDir(mySession);
|
||||
tr_logAddInfo(fmt::format(_("Reloading settings from '{path}'"), fmt::arg("path", configDir)));
|
||||
tr_logAddInfo(fmt::format(_("Reloading settings from '{path}'"), fmt::arg("path", ddata->configDir)));
|
||||
tr_variantInitDict(&settings, 0);
|
||||
tr_variantDictAddBool(&settings, TR_KEY_rpc_enabled, true);
|
||||
tr_sessionLoadSettings(&settings, configDir, MyName);
|
||||
tr_sessionLoadSettings(&settings, ddata->configDir, MyName);
|
||||
tr_sessionSet(mySession, &settings);
|
||||
tr_variantFree(&settings);
|
||||
tr_sessionReloadBlocklists(mySession);
|
||||
|
|
|
@ -156,7 +156,7 @@ private:
|
|||
private:
|
||||
Application& app_;
|
||||
|
||||
std::string config_dir_;
|
||||
std::string const config_dir_;
|
||||
bool start_paused_ = false;
|
||||
bool is_iconified_ = false;
|
||||
bool is_closing_ = false;
|
||||
|
@ -555,7 +555,7 @@ void Application::Impl::on_startup()
|
|||
|
||||
gtr_pref_flag_set(TR_KEY_alt_speed_enabled, tr_sessionUsesAltSpeed(session));
|
||||
gtr_pref_int_set(TR_KEY_peer_port, tr_sessionGetPeerPort(session));
|
||||
core_ = Session::create(session);
|
||||
core_ = Session::create(session, config_dir_);
|
||||
|
||||
/* init the ui manager */
|
||||
ui_builder_ = Gtk::Builder::create_from_resource(gtr_get_full_resource_path("transmission-ui.xml"s));
|
||||
|
|
|
@ -84,7 +84,7 @@ private:
|
|||
class Session::Impl
|
||||
{
|
||||
public:
|
||||
Impl(Session& core, tr_session* session);
|
||||
Impl(Session& core, tr_session* session, std::string_view config_dir);
|
||||
|
||||
tr_session* close();
|
||||
|
||||
|
@ -153,6 +153,7 @@ private:
|
|||
|
||||
private:
|
||||
Session& core_;
|
||||
std::string const config_dir_;
|
||||
|
||||
Glib::RefPtr<Gio::FileMonitor> monitor_;
|
||||
sigc::connection monitor_tag_;
|
||||
|
@ -799,22 +800,23 @@ void Session::Impl::on_pref_changed(tr_quark const key)
|
|||
***
|
||||
**/
|
||||
|
||||
Glib::RefPtr<Session> Session::create(tr_session* session)
|
||||
Glib::RefPtr<Session> Session::create(tr_session* session, std::string_view config_dir)
|
||||
{
|
||||
return Glib::make_refptr_for_instance(new Session(session));
|
||||
return Glib::make_refptr_for_instance(new Session(session, config_dir));
|
||||
}
|
||||
|
||||
Session::Session(tr_session* session)
|
||||
Session::Session(tr_session* session, std::string_view config_dir)
|
||||
: Glib::ObjectBase(typeid(Session))
|
||||
, impl_(std::make_unique<Impl>(*this, session))
|
||||
, impl_(std::make_unique<Impl>(*this, session, config_dir))
|
||||
{
|
||||
}
|
||||
|
||||
Session::~Session() = default;
|
||||
|
||||
Session::Impl::Impl(Session& core, tr_session* session)
|
||||
: core_(core)
|
||||
, session_(session)
|
||||
Session::Impl::Impl(Session& core, tr_session* session, std::string_view config_dir)
|
||||
: core_{ core }
|
||||
, config_dir_{ config_dir }
|
||||
, session_{ session }
|
||||
{
|
||||
raw_model_ = Gtk::ListStore::create(torrent_cols);
|
||||
sorted_model_ = Gtk::TreeModelSort::create(raw_model_);
|
||||
|
@ -1011,13 +1013,12 @@ tr_torrent* Session::Impl::create_new_torrent(tr_ctor* ctor)
|
|||
|
||||
if (tor != nullptr && do_trash)
|
||||
{
|
||||
char const* config = tr_sessionGetConfigDir(session_);
|
||||
char const* source = tr_ctorGetSourceFile(ctor);
|
||||
|
||||
if (source != nullptr)
|
||||
{
|
||||
/* #1294: don't delete the .torrent file if it's our internal copy */
|
||||
bool const is_internal = strstr(source, config) == source;
|
||||
bool const is_internal = strstr(source, config_dir_.c_str()) == source;
|
||||
|
||||
if (!is_internal)
|
||||
{
|
||||
|
|
|
@ -32,7 +32,7 @@ public:
|
|||
|
||||
TR_DISABLE_COPY_MOVE(Session)
|
||||
|
||||
static Glib::RefPtr<Session> create(tr_session* session);
|
||||
static Glib::RefPtr<Session> create(tr_session* session, std::string_view config_dir);
|
||||
|
||||
tr_session* close();
|
||||
|
||||
|
@ -130,7 +130,7 @@ public:
|
|||
sigc::signal<void(bool)>& signal_port_tested();
|
||||
|
||||
protected:
|
||||
explicit Session(tr_session* session);
|
||||
explicit Session(tr_session* session, std::string_view config_dir);
|
||||
|
||||
private:
|
||||
class Impl;
|
||||
|
|
|
@ -124,33 +124,6 @@ static std::string xdgConfigHome()
|
|||
return tr_strvPath(getHomeDir(), ".config"sv);
|
||||
}
|
||||
|
||||
void tr_setConfigDir(tr_session* session, std::string_view config_dir)
|
||||
{
|
||||
#if defined(__APPLE__) || defined(_WIN32)
|
||||
auto constexpr ResumeSubdir = "Resume"sv;
|
||||
auto constexpr TorrentSubdir = "Torrents"sv;
|
||||
#else
|
||||
auto constexpr ResumeSubdir = "resume"sv;
|
||||
auto constexpr TorrentSubdir = "torrents"sv;
|
||||
#endif
|
||||
|
||||
session->config_dir = config_dir;
|
||||
session->resume_dir = tr_strvPath(config_dir, ResumeSubdir);
|
||||
session->torrent_dir = tr_strvPath(config_dir, TorrentSubdir);
|
||||
tr_sys_dir_create(session->resume_dir, TR_SYS_DIR_CREATE_PARENTS, 0777);
|
||||
tr_sys_dir_create(session->torrent_dir, TR_SYS_DIR_CREATE_PARENTS, 0777);
|
||||
}
|
||||
|
||||
char const* tr_sessionGetConfigDir(tr_session const* session)
|
||||
{
|
||||
return session->config_dir.c_str();
|
||||
}
|
||||
|
||||
char const* tr_getTorrentDir(tr_session const* session)
|
||||
{
|
||||
return session->torrent_dir.c_str();
|
||||
}
|
||||
|
||||
char const* tr_getDefaultConfigDir(char const* appname)
|
||||
{
|
||||
static char const* s = nullptr;
|
||||
|
@ -283,7 +256,7 @@ bool isWebClientDir(std::string_view path)
|
|||
static std::string getPlatformWebClientDir(tr_session const* session)
|
||||
{
|
||||
// look in the Application Support folder
|
||||
if (auto path = tr_pathbuf{ session->config_dir, "/public_html"sv }; isWebClientDir(path))
|
||||
if (auto path = tr_pathbuf{ session->configDir(), "/public_html"sv }; isWebClientDir(path))
|
||||
{
|
||||
return std::string{ path };
|
||||
}
|
||||
|
|
|
@ -19,17 +19,6 @@ struct tr_session;
|
|||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief invoked by tr_sessionInit() to set up the locations of the resume, torrent, and clutch directories.
|
||||
* @see tr_getResumeDir()
|
||||
* @see tr_getTorrentDir()
|
||||
* @see tr_getWebClientDir()
|
||||
*/
|
||||
void tr_setConfigDir(tr_session* session, std::string_view config_dir);
|
||||
|
||||
/** @brief return the directory where torrent files are stored */
|
||||
char const* tr_getTorrentDir(tr_session const*);
|
||||
|
||||
/** @brief return the directory where the Web Client's web ui files are kept */
|
||||
std::string tr_getWebClientDir(tr_session const*);
|
||||
|
||||
|
|
|
@ -655,7 +655,7 @@ static auto loadFromFile(tr_torrent* tor, tr_resume::fields_t fieldsToLoad, bool
|
|||
auto const wasDirty = tor->isDirty;
|
||||
|
||||
auto const migrated = tr_torrent_metainfo::migrateFile(
|
||||
tor->session->resume_dir,
|
||||
tor->session->resumeDir(),
|
||||
tor->name(),
|
||||
tor->infoHashString(),
|
||||
".resume"sv);
|
||||
|
|
|
@ -1444,7 +1444,7 @@ static void onBlocklistFetched(tr_web::FetchResponse const& web_response)
|
|||
|
||||
// tr_blocklistSetContent needs a source file,
|
||||
// so save content into a tmpfile
|
||||
auto const filename = tr_pathbuf{ session->config_dir, "/blocklist.tmp"sv };
|
||||
auto const filename = tr_pathbuf{ session->configDir(), "/blocklist.tmp"sv };
|
||||
if (tr_error* error = nullptr; !tr_saveFile(filename, content, &error))
|
||||
{
|
||||
tr_idle_function_done(
|
||||
|
@ -2171,7 +2171,7 @@ static void addSessionField(tr_session const* s, tr_variant* d, tr_quark key)
|
|||
break;
|
||||
|
||||
case TR_KEY_config_dir:
|
||||
tr_variantDictAddStr(d, key, tr_sessionGetConfigDir(s));
|
||||
tr_variantDictAddStr(d, key, s->configDir());
|
||||
break;
|
||||
|
||||
case TR_KEY_default_trackers:
|
||||
|
|
|
@ -46,7 +46,6 @@
|
|||
#include "peer-io.h"
|
||||
#include "peer-mgr.h"
|
||||
#include "platform-quota.h" /* tr_device_info_free() */
|
||||
#include "platform.h" /* tr_getTorrentDir() */
|
||||
#include "port-forwarding.h"
|
||||
#include "rpc-server.h"
|
||||
#include "session-id.h"
|
||||
|
@ -128,7 +127,7 @@ tr_peer_id_t tr_peerIdInit()
|
|||
|
||||
std::optional<std::string> tr_session::WebMediator::cookieFile() const
|
||||
{
|
||||
auto const path = tr_pathbuf{ session_->config_dir, "/cookies.txt" };
|
||||
auto const path = tr_pathbuf{ session_->configDir(), "/cookies.txt"sv };
|
||||
|
||||
if (!tr_sys_path_exists(path))
|
||||
{
|
||||
|
@ -726,7 +725,7 @@ static void tr_sessionInitImpl(init_data* data)
|
|||
|
||||
tr_logSetQueueEnabled(data->messageQueuingEnabled);
|
||||
|
||||
tr_setConfigDir(session, data->config_dir);
|
||||
session->initConfigDir(data->config_dir);
|
||||
|
||||
session->peerMgr = tr_peerMgrNew(session);
|
||||
|
||||
|
@ -736,7 +735,7 @@ static void tr_sessionInitImpl(init_data* data)
|
|||
*** Blocklist
|
||||
**/
|
||||
|
||||
tr_sys_dir_create(tr_pathbuf{ session->config_dir, "/blocklists"sv }, TR_SYS_DIR_CREATE_PARENTS, 0777);
|
||||
tr_sys_dir_create(tr_pathbuf{ session->configDir(), "/blocklists"sv }, TR_SYS_DIR_CREATE_PARENTS, 0777);
|
||||
loadBlocklists(session);
|
||||
|
||||
TR_ASSERT(tr_isSession(session));
|
||||
|
@ -2036,16 +2035,14 @@ static void sessionLoadTorrents(struct sessionLoadTorrentsData* const data)
|
|||
TR_ASSERT(tr_isSession(data->session));
|
||||
|
||||
tr_sys_path_info info;
|
||||
char const* const dirname = tr_getTorrentDir(data->session);
|
||||
tr_sys_dir_t odir = (tr_sys_path_get_info(dirname, 0, &info) && info.type == TR_SYS_PATH_IS_DIRECTORY) ?
|
||||
tr_sys_dir_open(dirname) :
|
||||
auto const& dirname = data->session->torrentDir();
|
||||
tr_sys_dir_t odir = (tr_sys_path_get_info(dirname.c_str(), 0, &info) && info.type == TR_SYS_PATH_IS_DIRECTORY) ?
|
||||
tr_sys_dir_open(dirname.c_str()) :
|
||||
TR_BAD_SYS_DIR;
|
||||
|
||||
auto torrents = std::list<tr_torrent*>{};
|
||||
if (odir != TR_BAD_SYS_DIR)
|
||||
{
|
||||
auto const dirname_sv = std::string_view{ dirname };
|
||||
|
||||
char const* name = nullptr;
|
||||
while ((name = tr_sys_dir_read_name(odir)) != nullptr)
|
||||
{
|
||||
|
@ -2054,7 +2051,7 @@ static void sessionLoadTorrents(struct sessionLoadTorrentsData* const data)
|
|||
continue;
|
||||
}
|
||||
|
||||
auto const path = tr_pathbuf{ dirname_sv, "/"sv, name };
|
||||
auto const path = tr_pathbuf{ dirname, '/', name };
|
||||
|
||||
// is a magnet link?
|
||||
if (!tr_ctorSetMetainfoFromFile(data->ctor, path.sv(), nullptr))
|
||||
|
@ -2352,7 +2349,7 @@ static void loadBlocklists(tr_session* session)
|
|||
auto const isEnabled = session->useBlocklist();
|
||||
|
||||
/* walk the blocklist directory... */
|
||||
auto const dirname = tr_pathbuf{ session->config_dir, "/blocklists"sv };
|
||||
auto const dirname = tr_pathbuf{ session->configDir(), "/blocklists"sv };
|
||||
auto const odir = tr_sys_dir_open(dirname);
|
||||
|
||||
if (odir == TR_BAD_SYS_DIR)
|
||||
|
@ -2492,7 +2489,7 @@ size_t tr_blocklistSetContent(tr_session* session, char const* contentFilename)
|
|||
BlocklistFile* b = nullptr;
|
||||
if (it == std::end(src))
|
||||
{
|
||||
auto path = tr_pathbuf{ session->config_dir, "/blocklists/"sv, name };
|
||||
auto path = tr_pathbuf{ session->configDir(), "/blocklists/"sv, name };
|
||||
src.push_back(std::make_unique<BlocklistFile>(path, session->useBlocklist()));
|
||||
b = std::rbegin(src)->get();
|
||||
}
|
||||
|
@ -2954,3 +2951,24 @@ void tr_session::closeTorrentFile(tr_torrent* tor, tr_file_index_t file_num) noe
|
|||
this->cache->flushFile(tor, file_num);
|
||||
openFiles().closeFile(tor->id(), file_num);
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
void tr_session::initConfigDir(std::string_view config_dir)
|
||||
{
|
||||
TR_ASSERT(std::empty(config_dir_));
|
||||
|
||||
#if defined(__APPLE__) || defined(_WIN32)
|
||||
auto constexpr ResumeSubdir = "Resume"sv;
|
||||
auto constexpr TorrentSubdir = "Torrents"sv;
|
||||
#else
|
||||
auto constexpr ResumeSubdir = "resume"sv;
|
||||
auto constexpr TorrentSubdir = "torrents"sv;
|
||||
#endif
|
||||
|
||||
config_dir_ = config_dir;
|
||||
resume_dir_ = tr_strvPath(config_dir, ResumeSubdir);
|
||||
torrent_dir_ = tr_strvPath(config_dir, TorrentSubdir);
|
||||
tr_sys_dir_create(resume_dir_, TR_SYS_DIR_CREATE_PARENTS, 0777);
|
||||
tr_sys_dir_create(torrent_dir_, TR_SYS_DIR_CREATE_PARENTS, 0777);
|
||||
}
|
||||
|
|
|
@ -396,13 +396,26 @@ public:
|
|||
public_peer_port = port;
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr auto const& configDir() const noexcept
|
||||
{
|
||||
return config_dir_;
|
||||
}
|
||||
|
||||
void initConfigDir(std::string_view config_dir);
|
||||
|
||||
[[nodiscard]] constexpr auto const& resumeDir() const noexcept
|
||||
{
|
||||
return resume_dir_;
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr auto const& torrentDir() const noexcept
|
||||
{
|
||||
return torrent_dir_;
|
||||
}
|
||||
|
||||
tr_port randomPortLow;
|
||||
tr_port randomPortHigh;
|
||||
|
||||
std::string config_dir;
|
||||
std::string resume_dir;
|
||||
std::string torrent_dir;
|
||||
|
||||
std::vector<std::unique_ptr<BlocklistFile>> blocklists;
|
||||
struct tr_peerMgr* peerMgr = nullptr;
|
||||
struct tr_shared* shared = nullptr;
|
||||
|
@ -473,6 +486,9 @@ private:
|
|||
tr_torrents torrents_;
|
||||
|
||||
std::array<std::string, TR_SCRIPT_N_TYPES> scripts_;
|
||||
std::string config_dir_;
|
||||
std::string resume_dir_;
|
||||
std::string torrent_dir_;
|
||||
std::string blocklist_url_;
|
||||
std::string download_dir_;
|
||||
std::string default_trackers_str_;
|
||||
|
|
|
@ -34,14 +34,14 @@ static void loadCumulativeStats(tr_session const* session, tr_session_stats* set
|
|||
{
|
||||
auto top = tr_variant{};
|
||||
|
||||
auto filename = tr_pathbuf{ session->config_dir, "/stats.json"sv };
|
||||
auto filename = tr_pathbuf{ session->configDir(), "/stats.json"sv };
|
||||
bool loaded = tr_variantFromFile(&top, TR_VARIANT_PARSE_JSON, filename.sv(), nullptr);
|
||||
|
||||
if (!loaded)
|
||||
{
|
||||
// maybe the user just upgraded from an old version of Transmission
|
||||
// that was still using stats.benc
|
||||
filename.assign(session->config_dir, "/stats.benc");
|
||||
filename.assign(session->configDir(), "/stats.benc"sv);
|
||||
loaded = tr_variantFromFile(&top, TR_VARIANT_PARSE_BENC, filename.sv(), nullptr);
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ static void loadCumulativeStats(tr_session const* session, tr_session_stats* set
|
|||
|
||||
static void saveCumulativeStats(tr_session const* session, tr_session_stats const* s)
|
||||
{
|
||||
auto const filename = tr_pathbuf{ session->config_dir, "/stats.json"sv };
|
||||
auto const filename = tr_pathbuf{ session->configDir(), "/stats.json"sv };
|
||||
auto top = tr_variant{};
|
||||
tr_variantInitDict(&top, 5);
|
||||
tr_variantDictAddInt(&top, TR_KEY_downloaded_bytes, s->downloadedBytes);
|
||||
|
|
|
@ -766,7 +766,7 @@ static void torrentInit(tr_torrent* tor, tr_ctor const* ctor)
|
|||
|
||||
if (resume_file_was_migrated)
|
||||
{
|
||||
tr_torrent_metainfo::migrateFile(session->torrent_dir, tor->name(), tor->infoHashString(), ".torrent"sv);
|
||||
tr_torrent_metainfo::migrateFile(session->torrentDir(), tor->name(), tor->infoHashString(), ".torrent"sv);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1624,9 +1624,9 @@ static void closeTorrent(tr_torrent* const tor)
|
|||
|
||||
if (tor->isDeleting)
|
||||
{
|
||||
tr_torrent_metainfo::removeFile(tor->session->torrent_dir, tor->name(), tor->infoHashString(), ".torrent"sv);
|
||||
tr_torrent_metainfo::removeFile(tor->session->torrent_dir, tor->name(), tor->infoHashString(), ".magnet"sv);
|
||||
tr_torrent_metainfo::removeFile(tor->session->resume_dir, tor->name(), tor->infoHashString(), ".resume"sv);
|
||||
tr_torrent_metainfo::removeFile(tor->session->torrentDir(), tor->name(), tor->infoHashString(), ".torrent"sv);
|
||||
tr_torrent_metainfo::removeFile(tor->session->torrentDir(), tor->name(), tor->infoHashString(), ".magnet"sv);
|
||||
tr_torrent_metainfo::removeFile(tor->session->resumeDir(), tor->name(), tor->infoHashString(), ".resume"sv);
|
||||
}
|
||||
|
||||
tor->isRunning = false;
|
||||
|
|
|
@ -450,17 +450,17 @@ public:
|
|||
|
||||
[[nodiscard]] auto torrentFile() const
|
||||
{
|
||||
return metainfo_.torrentFile(this->session->torrent_dir);
|
||||
return metainfo_.torrentFile(this->session->torrentDir());
|
||||
}
|
||||
|
||||
[[nodiscard]] auto magnetFile() const
|
||||
{
|
||||
return metainfo_.magnetFile(this->session->torrent_dir);
|
||||
return metainfo_.magnetFile(this->session->torrentDir());
|
||||
}
|
||||
|
||||
[[nodiscard]] auto resumeFile() const
|
||||
{
|
||||
return metainfo_.resumeFile(this->session->resume_dir);
|
||||
return metainfo_.resumeFile(this->session->torrentDir());
|
||||
}
|
||||
|
||||
[[nodiscard]] auto magnet() const
|
||||
|
|
|
@ -146,7 +146,7 @@ static void dht_boostrap_from_file(tr_session* session)
|
|||
}
|
||||
|
||||
// check for a manual bootstrap file.
|
||||
auto in = std::ifstream{ tr_pathbuf{ session->config_dir, "/dht.bootstrap"sv } };
|
||||
auto in = std::ifstream{ tr_pathbuf{ session->configDir(), "/dht.bootstrap"sv } };
|
||||
if (!in.is_open())
|
||||
{
|
||||
return;
|
||||
|
@ -292,7 +292,7 @@ int tr_dhtInit(tr_session* ss)
|
|||
}
|
||||
|
||||
auto benc = tr_variant{};
|
||||
auto const dat_file = tr_pathbuf{ ss->config_dir, "/dht.dat"sv };
|
||||
auto const dat_file = tr_pathbuf{ ss->configDir(), "/dht.dat"sv };
|
||||
auto const ok = tr_variantFromFile(&benc, TR_VARIANT_PARSE_BENC, dat_file.sv());
|
||||
|
||||
bool have_id = false;
|
||||
|
@ -443,7 +443,7 @@ void tr_dhtUninit(tr_session* ss)
|
|||
tr_variantDictAddRaw(&benc, TR_KEY_nodes6, compact6, out6 - compact6);
|
||||
}
|
||||
|
||||
auto const dat_file = tr_pathbuf{ ss->config_dir, "/dht.dat" };
|
||||
auto const dat_file = tr_pathbuf{ ss->configDir(), "/dht.dat"sv };
|
||||
tr_variantToFile(&benc, TR_VARIANT_FMT_BENC, dat_file.sv());
|
||||
tr_variantFree(&benc);
|
||||
}
|
||||
|
|
|
@ -231,15 +231,6 @@ void tr_sessionReloadBlocklists(tr_session* session);
|
|||
@see tr_sessionInit() */
|
||||
void tr_sessionClose(tr_session*);
|
||||
|
||||
/**
|
||||
* @brief Return the session's configuration directory.
|
||||
*
|
||||
* This is where transmission stores its torrent files, .resume files,
|
||||
* blocklists, etc. It's set in tr_transmissionInit() and is immutable
|
||||
* during the session.
|
||||
*/
|
||||
char const* tr_sessionGetConfigDir(tr_session const*);
|
||||
|
||||
/**
|
||||
* @brief Set the per-session default download folder for new torrents.
|
||||
* @see tr_sessionInit()
|
||||
|
@ -703,7 +694,7 @@ void tr_torrentSetQueueStartCallback(tr_torrent* torrent, void (*callback)(tr_to
|
|||
***/
|
||||
|
||||
/**
|
||||
* Load all the torrents in tr_getTorrentDir().
|
||||
* Load all the torrents in the session's torrent folder.
|
||||
* This can be used at startup to kickstart all the torrents
|
||||
* from the previous session.
|
||||
*/
|
||||
|
@ -1156,7 +1147,7 @@ char* tr_torrentGetTrackerList(tr_torrent const* tor);
|
|||
* URL per line and a blank line between tiers.
|
||||
*
|
||||
* This updates both the `torrent' object's tracker list
|
||||
* and the metainfo file in tr_sessionGetConfigDir()'s torrent subdirectory.
|
||||
* and the metainfo file in the session config dir's torrent subdirectory.
|
||||
*/
|
||||
bool tr_torrentSetTrackerList(tr_torrent* tor, char const* text);
|
||||
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
#include "test-fixtures.h"
|
||||
|
||||
using namespace std::literals;
|
||||
|
||||
namespace libtransmission
|
||||
{
|
||||
|
||||
|
@ -69,7 +71,7 @@ TEST_F(BlocklistTest, parsing)
|
|||
EXPECT_EQ(0U, tr_blocklistGetRuleCount(session_));
|
||||
|
||||
// init the blocklist
|
||||
auto const path = tr_pathbuf{ tr_sessionGetConfigDir(session_), "/blocklists/level1" };
|
||||
auto const path = tr_pathbuf{ session_->configDir(), "/blocklists/level1"sv };
|
||||
createFileWithContents(path, Contents1);
|
||||
tr_sessionReloadBlocklists(session_);
|
||||
EXPECT_TRUE(tr_blocklistExists(session_));
|
||||
|
@ -105,7 +107,7 @@ TEST_F(BlocklistTest, parsing)
|
|||
TEST_F(BlocklistTest, updating)
|
||||
{
|
||||
// init the session
|
||||
auto const path = tr_pathbuf{ tr_sessionGetConfigDir(session_), "/blocklists/level1" };
|
||||
auto const path = tr_pathbuf{ session_->configDir(), "/blocklists/level1"sv };
|
||||
|
||||
// no blocklist to start with...
|
||||
EXPECT_EQ(0U, tr_blocklistGetRuleCount(session_));
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include "error.h"
|
||||
#include "file.h"
|
||||
#include "session.h"
|
||||
#include "tr-macros.h"
|
||||
#include "tr-strbuf.h"
|
||||
|
||||
|
@ -50,7 +51,7 @@ class FileTest : public SessionTest
|
|||
protected:
|
||||
auto createTestDir(std::string const& child_name)
|
||||
{
|
||||
auto test_dir = tr_pathbuf{ tr_sessionGetConfigDir(session_), '/', child_name };
|
||||
auto test_dir = tr_pathbuf{ session_->configDir(), '/', child_name };
|
||||
tr_sys_dir_create(test_dir, 0, 0777);
|
||||
return test_dir;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include "cache.h" // tr_cacheWriteBlock()
|
||||
#include "file.h" // tr_sys_path_*()
|
||||
#include "session.h"
|
||||
#include "tr-strbuf.h"
|
||||
#include "utils.h"
|
||||
#include "variant.h"
|
||||
|
@ -156,7 +157,7 @@ using MoveTest = SessionTest;
|
|||
|
||||
TEST_F(MoveTest, setLocation)
|
||||
{
|
||||
auto const target_dir = tr_pathbuf{ tr_sessionGetConfigDir(session_), "/target"sv };
|
||||
auto const target_dir = tr_pathbuf{ session_->configDir(), "/target"sv };
|
||||
tr_sys_dir_create(target_dir.data(), TR_SYS_DIR_CREATE_PARENTS, 0777, nullptr);
|
||||
|
||||
// init a torrent.
|
||||
|
|
Loading…
Reference in New Issue