From 273dee180c7b4dd9f30df3c4f1934353c9ed6897 Mon Sep 17 00:00:00 2001 From: Idan Geraffi Date: Fri, 16 Feb 2024 22:03:22 +0200 Subject: [PATCH 1/8] [ProtocolDetector] Added detector for aria2 control file --- .gitignore | 1 + src/File.cc | 5 +++++ src/File.h | 2 ++ src/ProtocolDetector.cc | 13 +++++++++++++ src/ProtocolDetector.h | 4 ++++ src/download_helper.cc | 6 ++++++ test/ProtocolDetectorTest.cc | 10 ++++++++++ 7 files changed, 41 insertions(+) diff --git a/.gitignore b/.gitignore index 282ebe32..69a81a20 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,4 @@ compile main.log main.trs test-suite.log +.vscode/ diff --git a/src/File.cc b/src/File.cc index a98dca61..753fdcc4 100644 --- a/src/File.cc +++ b/src/File.cc @@ -372,6 +372,11 @@ Time File::getModifiedTime() return Time(fstat.st_mtime); } +std::string File::getExtension() const +{ + return name_.substr(name_.find_last_of(".")); +} + std::string File::getCurrentDir() { #ifdef __MINGW32__ diff --git a/src/File.h b/src/File.h index 6d304640..85a69a5d 100644 --- a/src/File.h +++ b/src/File.h @@ -120,6 +120,8 @@ public: Time getModifiedTime(); + std::string getExtension() const; + // Returns the current working directory. If the current working // directory cannot be retrieved or its length is larger than 2048, // returns ".". diff --git a/src/ProtocolDetector.cc b/src/ProtocolDetector.cc index cc7016fc..1e496202 100644 --- a/src/ProtocolDetector.cc +++ b/src/ProtocolDetector.cc @@ -46,6 +46,7 @@ #ifdef ENABLE_BITTORRENT # include "bittorrent_helper.h" #endif // ENABLE_BITTORRENT +#include "DefaultBtProgressInfoFile.h" namespace aria2 { @@ -107,4 +108,16 @@ 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 diff --git a/src/ProtocolDetector.h b/src/ProtocolDetector.h index 54652cb1..a638eb24 100644 --- a/src/ProtocolDetector.h +++ b/src/ProtocolDetector.h @@ -60,6 +60,10 @@ public: // Returns true if ProtocolDetector thinks uri is a path of Metalink XML // file, otherwise return false. bool guessMetalinkFile(const std::string& uri) const; + + // Returns true if ProtocolDetector thinks uri is a path to aria2 control + // file, otherwise return false + bool guessAria2ControlFile(const std::string& uri) const; }; } // namespace aria2 diff --git a/src/download_helper.cc b/src/download_helper.cc index 6118aa14..ca903f71 100644 --- a/src/download_helper.cc +++ b/src/download_helper.cc @@ -445,7 +445,13 @@ public: } } } + #endif // ENABLE_METALINK +//TOOD: ifdef of ENABLE aria2 + else if (!ignoreLocalPath_ && detector_.guessAria2ControlFile(uri)) + { + + } else { if (throwOnError_) { throw DL_ABORT_EX(fmt(MSG_UNRECOGNIZED_URI, uri.c_str())); diff --git a/test/ProtocolDetectorTest.cc b/test/ProtocolDetectorTest.cc index a2b6c790..3d5d988b 100644 --- a/test/ProtocolDetectorTest.cc +++ b/test/ProtocolDetectorTest.cc @@ -14,6 +14,7 @@ class ProtocolDetectorTest : public CppUnit::TestFixture { CPPUNIT_TEST(testGuessTorrentFile); CPPUNIT_TEST(testGuessTorrentMagnet); CPPUNIT_TEST(testGuessMetalinkFile); + CPPUNIT_TEST(testGuessAria2ControlFile); CPPUNIT_TEST_SUITE_END(); public: @@ -25,6 +26,7 @@ public: void testGuessTorrentFile(); void testGuessTorrentMagnet(); void testGuessMetalinkFile(); + void testGuessAria2ControlFile(); }; CPPUNIT_TEST_SUITE_REGISTRATION(ProtocolDetectorTest); @@ -66,4 +68,12 @@ void ProtocolDetectorTest::testGuessMetalinkFile() CPPUNIT_ASSERT(!detector.guessMetalinkFile(A2_TEST_DIR "/test.torrent")); } +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")); +} + } // namespace aria2 From b06903bb4ed32df38c7adf1a5b9db021643a2809 Mon Sep 17 00:00:00 2001 From: Idan Geraffi Date: Sat, 17 Feb 2024 12:50:50 +0200 Subject: [PATCH 2/8] [DetectorTest] Fixed ControlFile test --- src/ProtocolDetector.cc | 1 + src/download_helper.cc | 10 +++++++++- test/ProtocolDetectorTest.cc | 2 +- test/control_file.aria | Bin 0 -> 213 bytes test/control_file.aria2 | Bin 0 -> 213 bytes 5 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 test/control_file.aria create mode 100644 test/control_file.aria2 diff --git a/src/ProtocolDetector.cc b/src/ProtocolDetector.cc index 1e496202..9a50a5a9 100644 --- a/src/ProtocolDetector.cc +++ b/src/ProtocolDetector.cc @@ -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; diff --git a/src/download_helper.cc b/src/download_helper.cc index ca903f71..93d19ee2 100644 --- a/src/download_helper.cc +++ b/src/download_helper.cc @@ -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(); + // 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_) { diff --git a/test/ProtocolDetectorTest.cc b/test/ProtocolDetectorTest.cc index 3d5d988b..84d8ce30 100644 --- a/test/ProtocolDetectorTest.cc +++ b/test/ProtocolDetectorTest.cc @@ -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 diff --git a/test/control_file.aria b/test/control_file.aria new file mode 100644 index 0000000000000000000000000000000000000000..bcd66cac3cedc0b20194107af0bd63524dc5ce5e GIT binary patch literal 213 zcmZQzWME(bVUgD_{Qs>sUvs0zY~m5K(A{SG%ypRz3P2ekm{oUz1;PT8vys??kqH2f CHVoJR literal 0 HcmV?d00001 diff --git a/test/control_file.aria2 b/test/control_file.aria2 new file mode 100644 index 0000000000000000000000000000000000000000..bcd66cac3cedc0b20194107af0bd63524dc5ce5e GIT binary patch literal 213 zcmZQzWME(bVUgD_{Qs>sUvs0zY~m5K(A{SG%ypRz3P2ekm{oUz1;PT8vys??kqH2f CHVoJR literal 0 HcmV?d00001 From a5da420c011c87cf6c25bbba0bc1b12c0d915b60 Mon Sep 17 00:00:00 2001 From: Idan Geraffi Date: Sun, 18 Feb 2024 16:21:52 +0200 Subject: [PATCH 3/8] [getInfoHash] Extracted logic to third function --- src/DefaultBtProgressInfoFile.cc | 67 +++++++++++++++++++++++++------- src/DefaultBtProgressInfoFile.h | 7 ++++ 2 files changed, 60 insertions(+), 14 deletions(-) diff --git a/src/DefaultBtProgressInfoFile.cc b/src/DefaultBtProgressInfoFile.cc index 7907284f..2a59d863 100644 --- a/src/DefaultBtProgressInfoFile.cc +++ b/src/DefaultBtProgressInfoFile.cc @@ -55,9 +55,7 @@ #include "fmt.h" #include "array_fun.h" #include "DownloadContext.h" -#include "BufferedFile.h" #include "SHA1IOFile.h" -#include "BtConstants.h" #ifdef ENABLE_BITTORRENT # include "PeerStorage.h" # include "BtRuntime.h" @@ -223,23 +221,17 @@ void DefaultBtProgressInfoFile::save() } } -#define READ_CHECK(fp, ptr, count) \ +#define READ_CHECK_STATIC(fp, ptr, count, filename) \ if (fp.read((ptr), (count)) != (count)) { \ - throw DL_ABORT_EX(fmt(EX_SEGMENT_FILE_READ, filename_.c_str())); \ + throw DL_ABORT_EX(fmt(EX_SEGMENT_FILE_READ, filename.c_str())); \ } -// It is assumed that integers are saved as: -// 1) host byte order if version == 0000 -// 2) network byte order if version == 0001 -void DefaultBtProgressInfoFile::load() +#define READ_CHECK(fp, ptr, count) READ_CHECK_STATIC(fp, ptr, count, filename_) + +uint DefaultBtProgressInfoFile::getControlFileVersion(BufferedFile& fp, const std::string& filename) { - A2_LOG_INFO(fmt(MSG_LOADING_SEGMENT_FILE, filename_.c_str())); - BufferedFile fp(filename_.c_str(), BufferedFile::READ); - if (!fp) { - throw DL_ABORT_EX(fmt(EX_SEGMENT_FILE_READ, filename_.c_str())); - } unsigned char versionBuf[2]; - READ_CHECK(fp, versionBuf, sizeof(versionBuf)); + READ_CHECK_STATIC(fp, versionBuf, sizeof(versionBuf), filename); std::string versionHex = util::toHex(versionBuf, sizeof(versionBuf)); int version; if ("0000" == versionHex) { @@ -252,6 +244,53 @@ void DefaultBtProgressInfoFile::load() throw DL_ABORT_EX( fmt("Unsupported ctrl file version: %s", versionHex.c_str())); } + + return version; +} + +std::array DefaultBtProgressInfoFile::getInfoHash(const std::string& control_file) +{ + A2_LOG_INFO(fmt(MSG_LOADING_SEGMENT_FILE, control_file.c_str())); + BufferedFile fp(control_file.c_str(), BufferedFile::READ); + if (!fp) { + throw DL_ABORT_EX(fmt(EX_SEGMENT_FILE_READ, control_file.c_str())); + } + + auto version = getControlFileVersion(fp, control_file); + + unsigned char extension[4]; + READ_CHECK_STATIC(fp, extension, sizeof(extension), control_file); + + uint32_t infoHashLength; + READ_CHECK_STATIC(fp, &infoHashLength, sizeof(infoHashLength), control_file); + if (version >= 1) { + infoHashLength = ntohl(infoHashLength); + } + if (infoHashLength != INFO_HASH_LENGTH) { + throw DL_ABORT_EX(fmt("Invalid info hash length: %d", infoHashLength)); + } + + std::array savedInfoHash; + if (infoHashLength > 0) { + READ_CHECK_STATIC(fp, savedInfoHash.data(), infoHashLength, control_file); + } + + return savedInfoHash; +} + +// It is assumed that integers are saved as: +// 1) host byte order if version == 0000 +// 2) network byte order if version == 0001 +void DefaultBtProgressInfoFile::load() +{ + A2_LOG_INFO(fmt(MSG_LOADING_SEGMENT_FILE, filename_.c_str())); + BufferedFile fp(filename_.c_str(), BufferedFile::READ); + if (!fp) { + throw DL_ABORT_EX(fmt(EX_SEGMENT_FILE_READ, filename_.c_str())); + } + + auto version = getControlFileVersion(fp, filename_); + unsigned char extension[4]; READ_CHECK(fp, extension, sizeof(extension)); bool infoHashCheckEnabled = false; diff --git a/src/DefaultBtProgressInfoFile.h b/src/DefaultBtProgressInfoFile.h index 33a28044..ef7a4a4a 100644 --- a/src/DefaultBtProgressInfoFile.h +++ b/src/DefaultBtProgressInfoFile.h @@ -36,6 +36,8 @@ #define D_DEFAULT_BT_PROGRESS_INFO_FILE_H #include "BtProgressInfoFile.h" +#include "BufferedFile.h" +#include "BtConstants.h" #include @@ -93,6 +95,11 @@ public: void setBtRuntime(const std::shared_ptr& btRuntime); #endif // ENABLE_BITTORRENT + // Assume getting pointer to the start of the file + static uint getControlFileVersion(BufferedFile& fp, const std::string& filename); + + static std::array getInfoHash(const std::string& control_file); + static const std::string& getSuffix() { static std::string suffix = ".aria2"; From 07676f7f9c4538167f4903dee541c1732cb2e5ef Mon Sep 17 00:00:00 2001 From: Idan Geraffi Date: Sun, 18 Feb 2024 16:33:52 +0200 Subject: [PATCH 4/8] [ControlFile] Make magent request from control file --- src/download_helper.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/download_helper.cc b/src/download_helper.cc index 93d19ee2..2879b8c3 100644 --- a/src/download_helper.cc +++ b/src/download_helper.cc @@ -70,6 +70,7 @@ // TODO ENABLE CONTROLFILE #include "TorrentAttribute.h" #include "bittorrent_helper.h" +#include "DefaultBtProgressInfoFile.h" namespace aria2 { @@ -453,9 +454,10 @@ public: else if (!ignoreLocalPath_ && detector_.guessAria2ControlFile(uri)) { // Extract hash and construct a magnet to feed into createBtMagentRequestGroup + const auto infoHash = DefaultBtProgressInfoFile::getInfoHash(uri); - auto torrent_attribute = std::make_unique(); - // torrent_attribute->infoHash = the hash from the file + auto torrent_attribute = std::make_unique(); + torrent_attribute->infoHash = std::string(std::begin(infoHash), std::end(infoHash)); const auto magent = aria2::bittorrent::torrent2Magnet(torrent_attribute.get()); requestGroups_.push_back(createBtMagnetRequestGroup(magent, option_)); From 3644f077ad7f7cdae509999d6f778948e65da11b Mon Sep 17 00:00:00 2001 From: Idan Geraffi Date: Sun, 18 Feb 2024 16:41:26 +0200 Subject: [PATCH 5/8] [Docs] Added control file option to docs --- doc/manual-src/en/aria2c.rst | 4 ++-- doc/manual-src/pt/aria2c.rst | 2 +- src/version_usage.cc | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/manual-src/en/aria2c.rst b/doc/manual-src/en/aria2c.rst index 6d54f361..4903f675 100644 --- a/doc/manual-src/en/aria2c.rst +++ b/doc/manual-src/en/aria2c.rst @@ -3,7 +3,7 @@ aria2c(1) SYNOPSIS -------- -**aria2c** [] [|||] ... +**aria2c** [] [||||] ... DESCRIPTION ----------- @@ -1736,7 +1736,7 @@ Some options takes ``K`` and ``M`` to conveniently represent 1024 and case-insensitive way. In other words, ``k`` and ``m`` can be used as well as ``K`` and ``M`` respectively. -URI, MAGNET, TORRENT_FILE, METALINK_FILE +URI, MAGNET, TORRENT_FILE, METALINK_FILE, CONTROL_FILE ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ You can specify multiple URIs in command-line. Unless you specify diff --git a/doc/manual-src/pt/aria2c.rst b/doc/manual-src/pt/aria2c.rst index ecb3a551..40516caa 100644 --- a/doc/manual-src/pt/aria2c.rst +++ b/doc/manual-src/pt/aria2c.rst @@ -1482,7 +1482,7 @@ Algumas opções usam ``K`` e ``M`` para convenientemente representar transparente (maiúsculas e minúsculas), portanto podem ser usados `k`` ou ``K`` e ``m`` ou ``M``. -URI, MAGNET, TORRENT_FILE, METALINK_FILE +URI, MAGNET, TORRENT_FILE, METALINK_FILE, CONTROL_FILE ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Podemos especificar múltiplas URIs em uma linha de comando. A menos que seja diff --git a/src/version_usage.cc b/src/version_usage.cc index d2218b44..d5590823 100644 --- a/src/version_usage.cc +++ b/src/version_usage.cc @@ -85,7 +85,7 @@ void showUsage(const std::string& keyword, const std::shared_ptr& oparser, const Console& out) { out->printf(_("Usage: aria2c [OPTIONS] [URI | MAGNET | TORRENT_FILE |" - " METALINK_FILE]...")); + " METALINK_FILE | CONTROL_FILE]...")); out->printf("\n"); if (keyword.empty()) { // Very short version of usage. @@ -139,7 +139,7 @@ void showUsage(const std::string& keyword, } } if (keyword == strHelpTag(TAG_BASIC)) { - out->printf("URI, MAGNET, TORRENT_FILE, METALINK_FILE:\n"); + out->printf("URI, MAGNET, TORRENT_FILE, METALINK_FILE, CONTROL_FILE:\n"); out->printf( _(" You can specify multiple HTTP(S)/FTP URIs. Unless you specify -Z " "option, all\n" From b408409f13746d59590012ffef5b509a82f8889d Mon Sep 17 00:00:00 2001 From: Idan Geraffi Date: Sun, 18 Feb 2024 16:54:34 +0200 Subject: [PATCH 6/8] [Docs] Added control file option to docs --- doc/manual-src/en/aria2c.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/manual-src/en/aria2c.rst b/doc/manual-src/en/aria2c.rst index 4903f675..c96330fb 100644 --- a/doc/manual-src/en/aria2c.rst +++ b/doc/manual-src/en/aria2c.rst @@ -3,7 +3,7 @@ aria2c(1) SYNOPSIS -------- -**aria2c** [] [||||] ... +**aria2c** [] [||||] ... DESCRIPTION ----------- @@ -1736,7 +1736,7 @@ Some options takes ``K`` and ``M`` to conveniently represent 1024 and case-insensitive way. In other words, ``k`` and ``m`` can be used as well as ``K`` and ``M`` respectively. -URI, MAGNET, TORRENT_FILE, METALINK_FILE, CONTROL_FILE +URI, MAGNET, TORRENT_FILE, METALINK_FILE, ARIA2_CONTROL_FILE ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ You can specify multiple URIs in command-line. Unless you specify From 9f27580f14cd95d8f433e11932491c36135cfc1b Mon Sep 17 00:00:00 2001 From: Idan Geraffi Date: Sun, 18 Feb 2024 17:14:44 +0200 Subject: [PATCH 7/8] [Config] Added support for ENABLE_CONTROL_FILE --- src/DefaultBtProgressInfoFile.cc | 4 ++-- src/ProtocolDetector.cc | 33 ++++++++++++++++++-------------- src/download_helper.cc | 12 +++++++----- 3 files changed, 28 insertions(+), 21 deletions(-) diff --git a/src/DefaultBtProgressInfoFile.cc b/src/DefaultBtProgressInfoFile.cc index 2a59d863..d7692206 100644 --- a/src/DefaultBtProgressInfoFile.cc +++ b/src/DefaultBtProgressInfoFile.cc @@ -256,7 +256,7 @@ std::array 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)); diff --git a/src/ProtocolDetector.cc b/src/ProtocolDetector.cc index 9a50a5a9..94ab2492 100644 --- a/src/ProtocolDetector.cc +++ b/src/ProtocolDetector.cc @@ -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 diff --git a/src/download_helper.cc b/src/download_helper.cc index 2879b8c3..155b5284 100644 --- a/src/download_helper.cc +++ b/src/download_helper.cc @@ -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 From 588ef22bc08ce020fd2d441b101b70793e11df57 Mon Sep 17 00:00:00 2001 From: Idan Geraffi Date: Wed, 21 Feb 2024 15:33:39 +0200 Subject: [PATCH 8/8] Beautify --- doc/manual-src/pt/aria2c.rst | 2 +- doc/manual-src/ru/aria2c.rst | 2 +- src/download_helper.cc | 2 +- src/version_usage.cc | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/manual-src/pt/aria2c.rst b/doc/manual-src/pt/aria2c.rst index 40516caa..a502f1e3 100644 --- a/doc/manual-src/pt/aria2c.rst +++ b/doc/manual-src/pt/aria2c.rst @@ -1482,7 +1482,7 @@ Algumas opções usam ``K`` e ``M`` para convenientemente representar transparente (maiúsculas e minúsculas), portanto podem ser usados `k`` ou ``K`` e ``m`` ou ``M``. -URI, MAGNET, TORRENT_FILE, METALINK_FILE, CONTROL_FILE +URI, MAGNET, TORRENT_FILE, METALINK_FILE, ARIA2_CONTROL_FILE ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Podemos especificar múltiplas URIs em uma linha de comando. A menos que seja diff --git a/doc/manual-src/ru/aria2c.rst b/doc/manual-src/ru/aria2c.rst index 7a4c9d65..d0d2c53d 100644 --- a/doc/manual-src/ru/aria2c.rst +++ b/doc/manual-src/ru/aria2c.rst @@ -1836,7 +1836,7 @@ URI, и это не то, что обычно вы ожидаете. регистра. Другими словами, ``k`` и ``m`` могут быть использованы также как ``K`` и ``M`` соответственно. -URI, MAGNET-ССЫЛКА, TORRENT-ФАЙЛ, METALINK-ФАЙЛ +URI, MAGNET-ССЫЛКА, TORRENT-ФАЙЛ, METALINK-ФАЙЛ, ARIA2_CONTROL_FILE ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Вы можете перечислить несколько URI в командной строке. Пока вы не указали diff --git a/src/download_helper.cc b/src/download_helper.cc index 155b5284..41771c9c 100644 --- a/src/download_helper.cc +++ b/src/download_helper.cc @@ -64,12 +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 #ifdef ENABLE_CONTROL_FILE # include "TorrentAttribute.h" -# include "bittorrent_helper.h" # include "DefaultBtProgressInfoFile.h" #endif // ENABLE_CONTROL_FILE diff --git a/src/version_usage.cc b/src/version_usage.cc index d5590823..9bd70177 100644 --- a/src/version_usage.cc +++ b/src/version_usage.cc @@ -85,7 +85,7 @@ void showUsage(const std::string& keyword, const std::shared_ptr& oparser, const Console& out) { out->printf(_("Usage: aria2c [OPTIONS] [URI | MAGNET | TORRENT_FILE |" - " METALINK_FILE | CONTROL_FILE]...")); + " METALINK_FILE | ARIA2_CONTROL_FILE]...")); out->printf("\n"); if (keyword.empty()) { // Very short version of usage. @@ -139,7 +139,7 @@ void showUsage(const std::string& keyword, } } if (keyword == strHelpTag(TAG_BASIC)) { - out->printf("URI, MAGNET, TORRENT_FILE, METALINK_FILE, CONTROL_FILE:\n"); + out->printf("URI, MAGNET, TORRENT_FILE, METALINK_FILE, ARIA2_CONTROL_FILE:\n"); out->printf( _(" You can specify multiple HTTP(S)/FTP URIs. Unless you specify -Z " "option, all\n"