mirror of https://github.com/aria2/aria2
Don't return hidden option from DownloadHandle::getOption and getGlobalOption
parent
45506573a8
commit
c688f51f2e
|
@ -481,7 +481,12 @@ const std::string& getGlobalOption(Session* session, const std::string& name)
|
||||||
{
|
{
|
||||||
const SharedHandle<DownloadEngine>& e =
|
const SharedHandle<DownloadEngine>& e =
|
||||||
session->context->reqinfo->getDownloadEngine();
|
session->context->reqinfo->getDownloadEngine();
|
||||||
return e->getOption()->get(option::k2p(name));
|
const Pref* pref = option::k2p(name);
|
||||||
|
if(OptionParser::getInstance()->find(pref)) {
|
||||||
|
return e->getOption()->get(pref);
|
||||||
|
} else {
|
||||||
|
return A2STR::NIL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyVals getGlobalOptions(Session* session)
|
KeyVals getGlobalOptions(Session* session)
|
||||||
|
@ -776,7 +781,12 @@ struct RequestGroupDH : public DownloadHandle {
|
||||||
}
|
}
|
||||||
virtual const std::string& getOption(const std::string& name)
|
virtual const std::string& getOption(const std::string& name)
|
||||||
{
|
{
|
||||||
return group->getOption()->get(option::k2p(name));
|
const Pref* pref = option::k2p(name);
|
||||||
|
if(OptionParser::getInstance()->find(pref)) {
|
||||||
|
return group->getOption()->get(pref);
|
||||||
|
} else {
|
||||||
|
return A2STR::NIL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
virtual KeyVals getOptions()
|
virtual KeyVals getOptions()
|
||||||
{
|
{
|
||||||
|
|
|
@ -179,6 +179,8 @@ void Aria2ApiTest::testChangeOption()
|
||||||
CPPUNIT_ASSERT(std::find(retopts.begin(), retopts.end(),
|
CPPUNIT_ASSERT(std::find(retopts.begin(), retopts.end(),
|
||||||
KeyVals::value_type("dir", "mydownload"))
|
KeyVals::value_type("dir", "mydownload"))
|
||||||
!= retopts.end());
|
!= retopts.end());
|
||||||
|
// Don't return hidden option
|
||||||
|
CPPUNIT_ASSERT(hd->getOption(PREF_STARTUP_IDLE_TIME->k).empty());
|
||||||
deleteDownloadHandle(hd);
|
deleteDownloadHandle(hd);
|
||||||
// failure with null gid
|
// failure with null gid
|
||||||
CPPUNIT_ASSERT_EQUAL(-1, changeOption(session_, (A2Gid)0, options));
|
CPPUNIT_ASSERT_EQUAL(-1, changeOption(session_, (A2Gid)0, options));
|
||||||
|
@ -205,7 +207,8 @@ void Aria2ApiTest::testChangeGlobalOption()
|
||||||
CPPUNIT_ASSERT_EQUAL(0, changeGlobalOption(session_, options));
|
CPPUNIT_ASSERT_EQUAL(0, changeGlobalOption(session_, options));
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("none"),
|
CPPUNIT_ASSERT_EQUAL(std::string("none"),
|
||||||
getGlobalOption(session_, PREF_FILE_ALLOCATION->k));
|
getGlobalOption(session_, PREF_FILE_ALLOCATION->k));
|
||||||
|
// Don't return hidden option
|
||||||
|
CPPUNIT_ASSERT(getGlobalOption(session_, PREF_STARTUP_IDLE_TIME->k).empty());
|
||||||
// failure with bad option value
|
// failure with bad option value
|
||||||
options.clear();
|
options.clear();
|
||||||
options.push_back(KeyVals::value_type(PREF_FILE_ALLOCATION->k, "foo"));
|
options.push_back(KeyVals::value_type(PREF_FILE_ALLOCATION->k, "foo"));
|
||||||
|
|
Loading…
Reference in New Issue