mirror of
https://github.com/transmission/transmission.git
synced 2026-02-15 07:26:49 +00:00
fix: cannot add magnet links from the command line (#8415)
This commit is contained in:
@@ -144,7 +144,7 @@ private:
|
|||||||
void inc_busy();
|
void inc_busy();
|
||||||
void dec_busy();
|
void dec_busy();
|
||||||
|
|
||||||
bool add(Glib::ustring const& name, bool do_start, bool do_prompt, bool do_notify);
|
bool add(Glib::ustring const& name_in, bool do_start, bool do_prompt, bool do_notify);
|
||||||
void add_file_async_callback(
|
void add_file_async_callback(
|
||||||
Glib::RefPtr<Gio::File> const& file,
|
Glib::RefPtr<Gio::File> const& file,
|
||||||
Glib::RefPtr<Gio::AsyncResult>& result,
|
Glib::RefPtr<Gio::AsyncResult>& result,
|
||||||
@@ -822,8 +822,18 @@ void Session::Impl::add_file_async_callback(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add `name,` which might be a local filename, a magnet link, or a URI.
|
// Add `name,` which might be a local filename, a magnet link, or a URI.
|
||||||
bool Session::Impl::add(Glib::ustring const& name, bool const do_start, bool const do_prompt, bool const do_notify)
|
bool Session::Impl::add(Glib::ustring const& name_in, bool const do_start, bool const do_prompt, bool const do_notify)
|
||||||
{
|
{
|
||||||
|
auto name = name_in;
|
||||||
|
|
||||||
|
// `gio::File` doesn't seem to know how to stringify magnet links correctly.
|
||||||
|
// Unfortunately there are some code paths that unavoidably use `gio::File`
|
||||||
|
// e.g. Gtk::Application::on_open() so we have to do this:
|
||||||
|
if (auto constexpr BrokenMagnetLinkPrefix = "magnet:///?"sv; tr_strv_starts_with(name.raw(), BrokenMagnetLinkPrefix))
|
||||||
|
{
|
||||||
|
name.replace(0, std::size(BrokenMagnetLinkPrefix), "magnet:?");
|
||||||
|
}
|
||||||
|
|
||||||
auto* const session = get_session();
|
auto* const session = get_session();
|
||||||
if (session == nullptr)
|
if (session == nullptr)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user