mirror of https://github.com/aria2/aria2
[DetectorTest] Fixed ControlFile test
parent
273dee180c
commit
b06903bb4e
|
@ -111,6 +111,7 @@ bool ProtocolDetector::guessMetalinkFile(const std::string& uri) const
|
||||||
bool ProtocolDetector::guessAria2ControlFile(const std::string& uri) const
|
bool ProtocolDetector::guessAria2ControlFile(const std::string& uri) const
|
||||||
{
|
{
|
||||||
File control_file(uri);
|
File control_file(uri);
|
||||||
|
|
||||||
if(!control_file.isFile())
|
if(!control_file.isFile())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -64,10 +64,12 @@
|
||||||
#include "download_handlers.h"
|
#include "download_handlers.h"
|
||||||
#include "SimpleRandomizer.h"
|
#include "SimpleRandomizer.h"
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
# include "bittorrent_helper.h"
|
|
||||||
# include "BtConstants.h"
|
# include "BtConstants.h"
|
||||||
# include "ValueBaseBencodeParser.h"
|
# include "ValueBaseBencodeParser.h"
|
||||||
#endif // ENABLE_BITTORRENT
|
#endif // ENABLE_BITTORRENT
|
||||||
|
// TODO ENABLE CONTROLFILE
|
||||||
|
#include "TorrentAttribute.h"
|
||||||
|
#include "bittorrent_helper.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -450,7 +452,13 @@ public:
|
||||||
//TOOD: ifdef of ENABLE aria2
|
//TOOD: ifdef of ENABLE aria2
|
||||||
else if (!ignoreLocalPath_ && detector_.guessAria2ControlFile(uri))
|
else if (!ignoreLocalPath_ && detector_.guessAria2ControlFile(uri))
|
||||||
{
|
{
|
||||||
|
// Extract hash and construct a magnet to feed into createBtMagentRequestGroup
|
||||||
|
|
||||||
|
auto torrent_attribute = std::make_unique<const TorrentAttribute>();
|
||||||
|
// torrent_attribute->infoHash = the hash from the file
|
||||||
|
const auto magent = aria2::bittorrent::torrent2Magnet(torrent_attribute.get());
|
||||||
|
|
||||||
|
requestGroups_.push_back(createBtMagnetRequestGroup(magent, option_));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (throwOnError_) {
|
if (throwOnError_) {
|
||||||
|
|
|
@ -73,7 +73,7 @@ void ProtocolDetectorTest::testGuessAria2ControlFile()
|
||||||
const ProtocolDetector detector;
|
const ProtocolDetector detector;
|
||||||
CPPUNIT_ASSERT(detector.guessAria2ControlFile(A2_TEST_DIR "/control_file.aria2"));
|
CPPUNIT_ASSERT(detector.guessAria2ControlFile(A2_TEST_DIR "/control_file.aria2"));
|
||||||
CPPUNIT_ASSERT(!detector.guessAria2ControlFile(A2_TEST_DIR));
|
CPPUNIT_ASSERT(!detector.guessAria2ControlFile(A2_TEST_DIR));
|
||||||
CPPUNIT_ASSERT(detector.guessAria2ControlFile(A2_TEST_DIR "/control_file.aria"));
|
CPPUNIT_ASSERT(!detector.guessAria2ControlFile(A2_TEST_DIR "/control_file.aria"));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue