mirror of
https://github.com/aria2/aria2.git
synced 2025-04-06 22:17:38 +03:00
[DetectorTest] Fixed ControlFile test
This commit is contained in:
parent
273dee180c
commit
b06903bb4e
5 changed files with 11 additions and 2 deletions
|
@ -111,6 +111,7 @@ bool ProtocolDetector::guessMetalinkFile(const std::string& uri) const
|
|||
bool ProtocolDetector::guessAria2ControlFile(const std::string& uri) const
|
||||
{
|
||||
File control_file(uri);
|
||||
|
||||
if(!control_file.isFile())
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -64,10 +64,12 @@
|
|||
#include "download_handlers.h"
|
||||
#include "SimpleRandomizer.h"
|
||||
#ifdef ENABLE_BITTORRENT
|
||||
# include "bittorrent_helper.h"
|
||||
# include "BtConstants.h"
|
||||
# include "ValueBaseBencodeParser.h"
|
||||
#endif // ENABLE_BITTORRENT
|
||||
// TODO ENABLE CONTROLFILE
|
||||
#include "TorrentAttribute.h"
|
||||
#include "bittorrent_helper.h"
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
@ -450,7 +452,13 @@ public:
|
|||
//TOOD: ifdef of ENABLE aria2
|
||||
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 {
|
||||
if (throwOnError_) {
|
||||
|
|
|
@ -73,7 +73,7 @@ void ProtocolDetectorTest::testGuessAria2ControlFile()
|
|||
const ProtocolDetector detector;
|
||||
CPPUNIT_ASSERT(detector.guessAria2ControlFile(A2_TEST_DIR "/control_file.aria2"));
|
||||
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
|
||||
|
|
BIN
test/control_file.aria
Normal file
BIN
test/control_file.aria
Normal file
Binary file not shown.
BIN
test/control_file.aria2
Normal file
BIN
test/control_file.aria2
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue