1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-01-05 06:23:11 +00:00

fix: does not trash added torrent files when asked (#5505)

This commit is contained in:
Charles Kerr 2023-05-08 16:21:54 -05:00 committed by GitHub
parent dd22b52bbf
commit cb6358048d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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();
} }