mirror of https://github.com/aria2/aria2
Added --hash-check-only opiton.
Added --hash-check-only opiton. If true is given, after hash check using --check-integrity option, abort download whether or not download is complete. The default value is false.pull/2/head
parent
0d36c466d9
commit
6c5c796646
|
@ -51,6 +51,9 @@ BtCheckIntegrityEntry::~BtCheckIntegrityEntry() {}
|
||||||
void BtCheckIntegrityEntry::onDownloadIncomplete
|
void BtCheckIntegrityEntry::onDownloadIncomplete
|
||||||
(std::vector<Command*>& commands, DownloadEngine* e)
|
(std::vector<Command*>& commands, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
|
if(getRequestGroup()->getOption()->getAsBool(PREF_HASH_CHECK_ONLY)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const SharedHandle<DiskAdaptor>& diskAdaptor =
|
const SharedHandle<DiskAdaptor>& diskAdaptor =
|
||||||
getRequestGroup()->getPieceStorage()->getDiskAdaptor();
|
getRequestGroup()->getPieceStorage()->getDiskAdaptor();
|
||||||
if(diskAdaptor->isReadOnlyEnabled()) {
|
if(diskAdaptor->isReadOnlyEnabled()) {
|
||||||
|
@ -71,7 +74,8 @@ void BtCheckIntegrityEntry::onDownloadFinished
|
||||||
// are valid, then aira2 goes to seeding mode. Sometimes it is better
|
// are valid, then aira2 goes to seeding mode. Sometimes it is better
|
||||||
// to exit rather than doing seeding. So, it would be good to toggle this
|
// to exit rather than doing seeding. So, it would be good to toggle this
|
||||||
// behavior.
|
// behavior.
|
||||||
if(getRequestGroup()->getOption()->getAsBool(PREF_BT_HASH_CHECK_SEED)) {
|
if(!getRequestGroup()->getOption()->getAsBool(PREF_HASH_CHECK_ONLY) &&
|
||||||
|
getRequestGroup()->getOption()->getAsBool(PREF_BT_HASH_CHECK_SEED)) {
|
||||||
SharedHandle<BtFileAllocationEntry> entry
|
SharedHandle<BtFileAllocationEntry> entry
|
||||||
(new BtFileAllocationEntry(getRequestGroup()));
|
(new BtFileAllocationEntry(getRequestGroup()));
|
||||||
proceedFileAllocation(commands, entry, e);
|
proceedFileAllocation(commands, entry, e);
|
||||||
|
|
|
@ -306,6 +306,20 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers()
|
||||||
op->addTag(TAG_BASIC);
|
op->addTag(TAG_BASIC);
|
||||||
handlers.push_back(op);
|
handlers.push_back(op);
|
||||||
}
|
}
|
||||||
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
|
{
|
||||||
|
SharedHandle<OptionHandler> op(new BooleanOptionHandler
|
||||||
|
(PREF_HASH_CHECK_ONLY,
|
||||||
|
TEXT_HASH_CHECK_ONLY,
|
||||||
|
A2_V_FALSE,
|
||||||
|
OptionHandler::OPT_ARG));
|
||||||
|
op->addTag(TAG_ADVANCED);
|
||||||
|
op->addTag(TAG_BITTORRENT);
|
||||||
|
op->addTag(TAG_METALINK);
|
||||||
|
op->addTag(TAG_FILE);
|
||||||
|
handlers.push_back(op);
|
||||||
|
}
|
||||||
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
{
|
{
|
||||||
SharedHandle<OptionHandler> op(new BooleanOptionHandler
|
SharedHandle<OptionHandler> op(new BooleanOptionHandler
|
||||||
(PREF_HUMAN_READABLE,
|
(PREF_HUMAN_READABLE,
|
||||||
|
|
|
@ -36,6 +36,8 @@
|
||||||
#include "RequestGroup.h"
|
#include "RequestGroup.h"
|
||||||
#include "DownloadEngine.h"
|
#include "DownloadEngine.h"
|
||||||
#include "StreamFileAllocationEntry.h"
|
#include "StreamFileAllocationEntry.h"
|
||||||
|
#include "prefs.h"
|
||||||
|
#include "Option.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -49,6 +51,9 @@ StreamCheckIntegrityEntry::~StreamCheckIntegrityEntry() {}
|
||||||
void StreamCheckIntegrityEntry::onDownloadIncomplete
|
void StreamCheckIntegrityEntry::onDownloadIncomplete
|
||||||
(std::vector<Command*>& commands, DownloadEngine* e)
|
(std::vector<Command*>& commands, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
|
if(getRequestGroup()->getOption()->getAsBool(PREF_HASH_CHECK_ONLY)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
SharedHandle<FileAllocationEntry> entry
|
SharedHandle<FileAllocationEntry> entry
|
||||||
(new StreamFileAllocationEntry(getRequestGroup(), popNextCommand()));
|
(new StreamFileAllocationEntry(getRequestGroup(), popNextCommand()));
|
||||||
proceedFileAllocation(commands, entry, e);
|
proceedFileAllocation(commands, entry, e);
|
||||||
|
|
|
@ -168,7 +168,8 @@ const std::set<std::string>& listRequestOptions()
|
||||||
PREF_RETRY_WAIT,
|
PREF_RETRY_WAIT,
|
||||||
PREF_METALINK_BASE_URI,
|
PREF_METALINK_BASE_URI,
|
||||||
PREF_PAUSE,
|
PREF_PAUSE,
|
||||||
PREF_STREAM_PIECE_SELECTOR
|
PREF_STREAM_PIECE_SELECTOR,
|
||||||
|
PREF_HASH_CHECK_ONLY
|
||||||
};
|
};
|
||||||
static std::set<std::string> requestOptions
|
static std::set<std::string> requestOptions
|
||||||
(vbegin(REQUEST_OPTIONS), vend(REQUEST_OPTIONS));
|
(vbegin(REQUEST_OPTIONS), vend(REQUEST_OPTIONS));
|
||||||
|
|
|
@ -221,6 +221,8 @@ const std::string PREF_TRUNCATE_CONSOLE_READOUT("truncate-console-readout");
|
||||||
const std::string PREF_PAUSE("pause");
|
const std::string PREF_PAUSE("pause");
|
||||||
// value: default | full
|
// value: default | full
|
||||||
const std::string PREF_DOWNLOAD_RESULT("download-result");
|
const std::string PREF_DOWNLOAD_RESULT("download-result");
|
||||||
|
// value: true | false
|
||||||
|
const std::string PREF_HASH_CHECK_ONLY("hash-check-only");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FTP related preferences
|
* FTP related preferences
|
||||||
|
|
|
@ -224,6 +224,8 @@ extern const std::string PREF_TRUNCATE_CONSOLE_READOUT;
|
||||||
extern const std::string PREF_PAUSE;
|
extern const std::string PREF_PAUSE;
|
||||||
// value: default | full
|
// value: default | full
|
||||||
extern const std::string PREF_DOWNLOAD_RESULT;
|
extern const std::string PREF_DOWNLOAD_RESULT;
|
||||||
|
// value: true | false
|
||||||
|
extern const std::string PREF_HASH_CHECK_ONLY;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FTP related preferences
|
* FTP related preferences
|
||||||
|
|
|
@ -818,3 +818,7 @@
|
||||||
" path/URI. The percentage of progress and\n" \
|
" path/URI. The percentage of progress and\n" \
|
||||||
" path/URI are printed for each requested file in\n" \
|
" path/URI are printed for each requested file in\n" \
|
||||||
" each row.")
|
" each row.")
|
||||||
|
#define TEXT_HASH_CHECK_ONLY \
|
||||||
|
_(" --hash-check-only[=true|false] If true is given, after hash check using\n" \
|
||||||
|
" --check-integrity option, abort download whether\n" \
|
||||||
|
" or not download is complete.")
|
||||||
|
|
Loading…
Reference in New Issue