mirror of
https://github.com/transmission/transmission.git
synced 2025-12-20 02:18:42 +00:00
fix: does not trash added torrent files when asked (#5505)
This commit is contained in:
@@ -1040,7 +1040,7 @@ void Session::addTorrent(AddData add_me, tr_variant* args_dict, bool trash_origi
|
|||||||
});
|
});
|
||||||
|
|
||||||
q->add(
|
q->add(
|
||||||
[this, add_me](RpcResponse const& r)
|
[this, add_me, trash_original](RpcResponse const& r)
|
||||||
{
|
{
|
||||||
bool session_has_torrent = false;
|
bool session_has_torrent = false;
|
||||||
|
|
||||||
@@ -1060,22 +1060,22 @@ void Session::addTorrent(AddData add_me, tr_variant* args_dict, bool trash_origi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (session_has_torrent && !add_me.filename.isEmpty())
|
if (auto const& filename = add_me.filename;
|
||||||
|
session_has_torrent && !filename.isEmpty() && add_me.type == AddData::FILENAME)
|
||||||
{
|
{
|
||||||
QFile(add_me.filename).rename(QStringLiteral("%1.added").arg(add_me.filename));
|
auto file = QFile{ filename };
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (trash_original && add_me.type == AddData::FILENAME)
|
if (trash_original)
|
||||||
{
|
{
|
||||||
q->add(
|
file.setPermissions(QFile::ReadOwner | QFile::WriteOwner);
|
||||||
[add_me]()
|
file.remove();
|
||||||
{
|
|
||||||
QFile original(add_me.filename);
|
|
||||||
original.setPermissions(QFile::ReadOwner | QFile::WriteOwner);
|
|
||||||
original.remove();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
file.rename(QStringLiteral("%1.added").arg(filename));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
q->run();
|
q->run();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user