mirror of https://github.com/aria2/aria2
[Config] Added support for ENABLE_CONTROL_FILE
parent
b408409f13
commit
9f27580f14
|
@ -256,7 +256,7 @@ std::array<unsigned char, INFO_HASH_LENGTH> DefaultBtProgressInfoFile::getInfoHa
|
|||
throw DL_ABORT_EX(fmt(EX_SEGMENT_FILE_READ, control_file.c_str()));
|
||||
}
|
||||
|
||||
auto version = getControlFileVersion(fp, control_file);
|
||||
const auto version = getControlFileVersion(fp, control_file);
|
||||
|
||||
unsigned char extension[4];
|
||||
READ_CHECK_STATIC(fp, extension, sizeof(extension), control_file);
|
||||
|
@ -289,7 +289,7 @@ void DefaultBtProgressInfoFile::load()
|
|||
throw DL_ABORT_EX(fmt(EX_SEGMENT_FILE_READ, filename_.c_str()));
|
||||
}
|
||||
|
||||
auto version = getControlFileVersion(fp, filename_);
|
||||
const auto version = getControlFileVersion(fp, filename_);
|
||||
|
||||
unsigned char extension[4];
|
||||
READ_CHECK(fp, extension, sizeof(extension));
|
||||
|
|
|
@ -46,7 +46,9 @@
|
|||
#ifdef ENABLE_BITTORRENT
|
||||
# include "bittorrent_helper.h"
|
||||
#endif // ENABLE_BITTORRENT
|
||||
#include "DefaultBtProgressInfoFile.h"
|
||||
#ifdef ENABLE_CONTROL_FILE
|
||||
# include "DefaultBtProgressInfoFile.h"
|
||||
#endif // ENABLE_CONTROL_FILE
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
@ -91,6 +93,22 @@ bool ProtocolDetector::guessTorrentMagnet(const std::string& uri) const
|
|||
#endif // !ENABLE_BITTORRENT
|
||||
}
|
||||
|
||||
bool ProtocolDetector::guessAria2ControlFile(const std::string& uri) const
|
||||
{
|
||||
#ifdef ENABLE_CONTROL_FILE
|
||||
File control_file(uri);
|
||||
|
||||
if(!control_file.isFile())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return control_file.getExtension() == DefaultBtProgressInfoFile::getSuffix();
|
||||
#else // !ENABLE_CONTROL_FILE
|
||||
return false;
|
||||
#endif // !ENABLE_CONTROL_FILE
|
||||
}
|
||||
|
||||
bool ProtocolDetector::guessMetalinkFile(const std::string& uri) const
|
||||
{
|
||||
BufferedFile fp(uri.c_str(), BufferedFile::READ);
|
||||
|
@ -108,17 +126,4 @@ 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;
|
||||
}
|
||||
|
||||
const auto control_file_suffix = DefaultBtProgressInfoFile::getSuffix();
|
||||
return control_file.getExtension() == control_file_suffix;
|
||||
}
|
||||
|
||||
} // namespace aria2
|
||||
|
|
|
@ -67,10 +67,11 @@
|
|||
# include "BtConstants.h"
|
||||
# include "ValueBaseBencodeParser.h"
|
||||
#endif // ENABLE_BITTORRENT
|
||||
// TODO ENABLE CONTROLFILE
|
||||
#include "TorrentAttribute.h"
|
||||
#include "bittorrent_helper.h"
|
||||
#include "DefaultBtProgressInfoFile.h"
|
||||
#ifdef ENABLE_CONTROL_FILE
|
||||
# include "TorrentAttribute.h"
|
||||
# include "bittorrent_helper.h"
|
||||
# include "DefaultBtProgressInfoFile.h"
|
||||
#endif // ENABLE_CONTROL_FILE
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
@ -450,7 +451,7 @@ public:
|
|||
}
|
||||
|
||||
#endif // ENABLE_METALINK
|
||||
//TOOD: ifdef of ENABLE aria2
|
||||
#ifdef ENABLE_CONTROL_FILE
|
||||
else if (!ignoreLocalPath_ && detector_.guessAria2ControlFile(uri))
|
||||
{
|
||||
// Extract hash and construct a magnet to feed into createBtMagentRequestGroup
|
||||
|
@ -471,6 +472,7 @@ public:
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_CONTROL_FILE
|
||||
};
|
||||
} // namespace
|
||||
|
||||
|
|
Loading…
Reference in New Issue