mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-14 16:57:55 +00:00
Simplify code
Instead of using dict_find_list() now we use the simpler dict_find() since we are going to check its validness anyway.
This commit is contained in:
parent
3a11c23efd
commit
f3ce76110b
@ -171,11 +171,6 @@ namespace
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isList(const lt::bdecode_node &entry)
|
|
||||||
{
|
|
||||||
return entry.type() == lt::bdecode_node::list_t;
|
|
||||||
}
|
|
||||||
|
|
||||||
QSet<QString> entryListToSet(const lt::bdecode_node &entry)
|
QSet<QString> entryListToSet(const lt::bdecode_node &entry)
|
||||||
{
|
{
|
||||||
return entryListToSetImpl(entry);
|
return entryListToSetImpl(entry);
|
||||||
@ -3667,13 +3662,13 @@ void Session::startUpTorrents()
|
|||||||
QStringList fastresumes = resumeDataDir.entryList(
|
QStringList fastresumes = resumeDataDir.entryList(
|
||||||
QStringList(QLatin1String("*.fastresume")), QDir::Files, QDir::Unsorted);
|
QStringList(QLatin1String("*.fastresume")), QDir::Files, QDir::Unsorted);
|
||||||
|
|
||||||
typedef struct
|
struct TorrentResumeData
|
||||||
{
|
{
|
||||||
QString hash;
|
QString hash;
|
||||||
MagnetUri magnetUri;
|
MagnetUri magnetUri;
|
||||||
CreateTorrentParams addTorrentData;
|
CreateTorrentParams addTorrentData;
|
||||||
QByteArray data;
|
QByteArray data;
|
||||||
} TorrentResumeData;
|
};
|
||||||
|
|
||||||
int resumedTorrentsCount = 0;
|
int resumedTorrentsCount = 0;
|
||||||
const auto startupTorrent = [this, &resumeDataDir, &resumedTorrentsCount](const TorrentResumeData ¶ms)
|
const auto startupTorrent = [this, &resumeDataDir, &resumedTorrentsCount](const TorrentResumeData ¶ms)
|
||||||
@ -4452,9 +4447,9 @@ namespace
|
|||||||
if (torrentParams.category.isEmpty())
|
if (torrentParams.category.isEmpty())
|
||||||
// **************************************************************************************
|
// **************************************************************************************
|
||||||
torrentParams.category = fromLTString(fast.dict_find_string_value("qBt-category"));
|
torrentParams.category = fromLTString(fast.dict_find_string_value("qBt-category"));
|
||||||
// auto because the return type depends on the #if above.
|
|
||||||
const auto tagsEntry = fast.dict_find_list("qBt-tags");
|
const lt::bdecode_node tagsEntry = fast.dict_find("qBt-tags");
|
||||||
if (isList(tagsEntry))
|
if (tagsEntry.type() == lt::bdecode_node::list_t)
|
||||||
torrentParams.tags = entryListToSet(tagsEntry);
|
torrentParams.tags = entryListToSet(tagsEntry);
|
||||||
torrentParams.name = fromLTString(fast.dict_find_string_value("qBt-name"));
|
torrentParams.name = fromLTString(fast.dict_find_string_value("qBt-name"));
|
||||||
torrentParams.hasSeedStatus = fast.dict_find_int_value("qBt-seedStatus");
|
torrentParams.hasSeedStatus = fast.dict_find_int_value("qBt-seedStatus");
|
||||||
|
Loading…
Reference in New Issue
Block a user