mirror of https://github.com/aria2/aria2
2007-07-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/main.cc (showUsage): Added 3 usage examples for metalink download. Replace MetalinkChunkChecksum with ChunkChecksum. * src/MetalinkChunkChecksum.h: Removed. * src/MetalinkEntry.h: MetalinkChunkChecksum -> ChunkChecksum. * src/Xml2MetalinkProcessor.h: MetalinkChunkChecksum -> ChunkChecksum. * src/Xml2MetalinkProcessor.cc (getPieceHash): Use ChunkChecksum instead of MetalinkChunkChecksum. * src/MetalinkRequestInfo.cc (execute)pull/1/head
parent
823056f0dd
commit
444bf5495d
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,16 @@
|
||||||
|
2007-07-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
|
* src/main.cc
|
||||||
|
(showUsage): Added 3 usage examples for metalink download.
|
||||||
|
|
||||||
|
Replace MetalinkChunkChecksum with ChunkChecksum.
|
||||||
|
* src/MetalinkChunkChecksum.h: Removed.
|
||||||
|
* src/MetalinkEntry.h: MetalinkChunkChecksum -> ChunkChecksum.
|
||||||
|
* src/Xml2MetalinkProcessor.h: MetalinkChunkChecksum -> ChunkChecksum.
|
||||||
|
* src/Xml2MetalinkProcessor.cc
|
||||||
|
(getPieceHash): Use ChunkChecksum instead of MetalinkChunkChecksum.
|
||||||
|
* src/MetalinkRequestInfo.cc (execute)
|
||||||
|
|
||||||
2007-07-06 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
2007-07-06 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
Reads URIs from stdin when "-i -" is specified.
|
Reads URIs from stdin when "-i -" is specified.
|
||||||
|
@ -7,7 +20,6 @@
|
||||||
* src/FileUriListParser.h: New class.
|
* src/FileUriListParser.h: New class.
|
||||||
* src/main.cc (main): Use StreamUriListParser and FileUriListParser
|
* src/main.cc (main): Use StreamUriListParser and FileUriListParser
|
||||||
instead of UriFileListParser.
|
instead of UriFileListParser.
|
||||||
(showUsage): Added 3 usage examples for metalink download.
|
|
||||||
|
|
||||||
2007-07-04 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
2007-07-04 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
|
|
|
@ -224,7 +224,6 @@ SRCS += Metalinker.cc Metalinker.h\
|
||||||
MetalinkProcessor.h\
|
MetalinkProcessor.h\
|
||||||
Xml2MetalinkProcessor.cc Xml2MetalinkProcessor.h\
|
Xml2MetalinkProcessor.cc Xml2MetalinkProcessor.h\
|
||||||
MetalinkRequestInfo.cc MetalinkRequestInfo.h
|
MetalinkRequestInfo.cc MetalinkRequestInfo.h
|
||||||
# MetalinkChunkChecksum.h
|
|
||||||
endif # ENABLE_METALINK
|
endif # ENABLE_METALINK
|
||||||
|
|
||||||
noinst_LIBRARIES = libaria2c.a
|
noinst_LIBRARIES = libaria2c.a
|
||||||
|
|
|
@ -670,7 +670,6 @@ SRCS = Socket.h SocketCore.cc SocketCore.h Command.cc Command.h \
|
||||||
CookieBoxFactory.h HttpHeaderProcessor.cc \
|
CookieBoxFactory.h HttpHeaderProcessor.cc \
|
||||||
HttpHeaderProcessor.h FileEntry.cc FileEntry.h $(am__append_1) \
|
HttpHeaderProcessor.h FileEntry.cc FileEntry.h $(am__append_1) \
|
||||||
$(am__append_2) $(am__append_3)
|
$(am__append_2) $(am__append_3)
|
||||||
# MetalinkChunkChecksum.h
|
|
||||||
noinst_LIBRARIES = libaria2c.a
|
noinst_LIBRARIES = libaria2c.a
|
||||||
libaria2c_a_SOURCES = $(SRCS)
|
libaria2c_a_SOURCES = $(SRCS)
|
||||||
aria2c_LDADD = libaria2c.a @LIBINTL@ @ALLOCA@ @LIBGNUTLS_LIBS@\
|
aria2c_LDADD = libaria2c.a @LIBINTL@ @ALLOCA@ @LIBGNUTLS_LIBS@\
|
||||||
|
|
|
@ -1,56 +0,0 @@
|
||||||
/* <!-- copyright */
|
|
||||||
/*
|
|
||||||
* aria2 - The high speed download utility
|
|
||||||
*
|
|
||||||
* Copyright (C) 2006 Tatsuhiro Tsujikawa
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
* In addition, as a special exception, the copyright holders give
|
|
||||||
* permission to link the code of portions of this program with the
|
|
||||||
* OpenSSL library under certain conditions as described in each
|
|
||||||
* individual source file, and distribute linked combinations
|
|
||||||
* including the two.
|
|
||||||
* You must obey the GNU General Public License in all respects
|
|
||||||
* for all of the code used other than OpenSSL. If you modify
|
|
||||||
* file(s) with this exception, you may extend this exception to your
|
|
||||||
* version of the file(s), but you are not obligated to do so. If you
|
|
||||||
* do not wish to do so, delete this exception statement from your
|
|
||||||
* version. If you delete this exception statement from all source
|
|
||||||
* files in the program, then also delete it here.
|
|
||||||
*/
|
|
||||||
/* copyright --> */
|
|
||||||
#ifndef _D_METALINK_CHUNK_CHECKSUM_H_
|
|
||||||
#define _D_METALINK_CHUNK_CHECKSUM_H_
|
|
||||||
|
|
||||||
#include "common.h"
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
#include "messageDigest.h"
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
class MetalinkChunkChecksum {
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
public:
|
|
||||||
MessageDigestContext::DigestAlgo digestAlgo;
|
|
||||||
int32_t pieceLength;
|
|
||||||
Strings pieceHashes;
|
|
||||||
public:
|
|
||||||
MetalinkChunkChecksum():pieceLength(0) {}
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef SharedHandle<MetalinkChunkChecksum> MetalinkChunkChecksumHandle;
|
|
||||||
|
|
||||||
#endif // _D_METALINK_CHUNK_CHECKSUM_H_
|
|
|
@ -38,8 +38,10 @@
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "MetalinkResource.h"
|
#include "MetalinkResource.h"
|
||||||
#include "Checksum.h"
|
#include "Checksum.h"
|
||||||
#include "MetalinkChunkChecksum.h"
|
|
||||||
#include "FileEntry.h"
|
#include "FileEntry.h"
|
||||||
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
|
#include "ChunkChecksum.h"
|
||||||
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
|
||||||
class MetalinkEntry;
|
class MetalinkEntry;
|
||||||
|
@ -57,7 +59,7 @@ public:
|
||||||
public:
|
public:
|
||||||
MetalinkResources resources;
|
MetalinkResources resources;
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
MetalinkChunkChecksumHandle chunkChecksum;
|
ChunkChecksumHandle chunkChecksum;
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
public:
|
public:
|
||||||
MetalinkEntry();
|
MetalinkEntry();
|
||||||
|
|
|
@ -152,11 +152,7 @@ RequestInfos MetalinkRequestInfo::execute() {
|
||||||
if(entry->chunkChecksum.isNull()) {
|
if(entry->chunkChecksum.isNull()) {
|
||||||
rg->setChecksum(checksum);
|
rg->setChecksum(checksum);
|
||||||
} else {
|
} else {
|
||||||
ChunkChecksumHandle cc =
|
rg->setChunkChecksum(entry->chunkChecksum);
|
||||||
new ChunkChecksum(entry->chunkChecksum->digestAlgo,
|
|
||||||
entry->chunkChecksum->pieceHashes,
|
|
||||||
entry->chunkChecksum->pieceLength);
|
|
||||||
rg->setChunkChecksum(cc);
|
|
||||||
}
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
groups.push_front(rg);
|
groups.push_front(rg);
|
||||||
|
|
|
@ -146,40 +146,39 @@ MetalinkEntryHandle Xml2MetalinkProcessor::getEntry(const string& xpath) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
MetalinkChunkChecksumHandle Xml2MetalinkProcessor::getPieceHash(const string& xpath,
|
ChunkChecksumHandle Xml2MetalinkProcessor::getPieceHash(const string& xpath,
|
||||||
int64_t totalSize)
|
int64_t totalSize)
|
||||||
{
|
{
|
||||||
MetalinkChunkChecksumHandle chunkChecksum = new MetalinkChunkChecksum();
|
|
||||||
|
|
||||||
xmlXPathObjectPtr result = xpathEvaluation(xpath);
|
xmlXPathObjectPtr result = xpathEvaluation(xpath);
|
||||||
if(!result) {
|
if(!result) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
xmlNodeSetPtr nodeSet = result->nodesetval;
|
xmlNodeSetPtr nodeSet = result->nodesetval;
|
||||||
xmlNodePtr node = nodeSet->nodeTab[0];
|
xmlNodePtr node = nodeSet->nodeTab[0];
|
||||||
chunkChecksum->pieceLength = STRTOLL(Util::trim(xmlAttribute(node, "length")).c_str());
|
|
||||||
string algo = Util::trim(xmlAttribute(node, "type"));
|
int64_t checksumLength = STRTOLL(Util::trim(xmlAttribute(node, "length")).c_str());
|
||||||
|
string algoString = Util::trim(xmlAttribute(node, "type"));
|
||||||
xmlXPathFreeObject(result);
|
xmlXPathFreeObject(result);
|
||||||
if(algo == "sha1") {
|
MessageDigestContext::DigestAlgo algo;
|
||||||
chunkChecksum->digestAlgo = DIGEST_ALGO_SHA1;
|
if(algoString == "sha1") {
|
||||||
} else if(algo == "md5") {
|
algo = DIGEST_ALGO_SHA1;
|
||||||
chunkChecksum->digestAlgo = DIGEST_ALGO_MD5;
|
} else if(algoString == "md5") {
|
||||||
|
algo = DIGEST_ALGO_MD5;
|
||||||
} else {
|
} else {
|
||||||
// unknown checksum type
|
// unknown checksum type
|
||||||
chunkChecksum->pieceLength = 0;
|
return 0;
|
||||||
return chunkChecksum;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t numPiece =
|
Strings checksums;
|
||||||
(totalSize+chunkChecksum->pieceLength-1)/chunkChecksum->pieceLength;
|
int64_t numPiece = (totalSize+checksumLength-1)/checksumLength;
|
||||||
for(int64_t i = 0; i < numPiece; ++i) {
|
for(int64_t i = 0; i < numPiece; ++i) {
|
||||||
string pieceHash = Util::trim(xpathContent(xpath+"/m:hash[@piece=\""+Util::ullitos(i)+"\"]"));
|
string pieceHash = Util::trim(xpathContent(xpath+"/m:hash[@piece=\""+Util::ullitos(i)+"\"]"));
|
||||||
if(pieceHash == "") {
|
if(pieceHash == "") {
|
||||||
throw new DlAbortEx("Piece hash missing. index=%d", i);
|
throw new DlAbortEx("Piece hash missing. index=%d", i);
|
||||||
}
|
}
|
||||||
chunkChecksum->pieceHashes.push_back(pieceHash);
|
checksums.push_back(pieceHash);
|
||||||
}
|
}
|
||||||
return chunkChecksum;
|
return new ChunkChecksum(algo, checksums, checksumLength);
|
||||||
}
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ private:
|
||||||
MetalinkResourceHandle getResource(const string& xpath);
|
MetalinkResourceHandle getResource(const string& xpath);
|
||||||
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
MetalinkChunkChecksumHandle getPieceHash(const string& xpath,
|
ChunkChecksumHandle getPieceHash(const string& xpath,
|
||||||
int64_t totalSize);
|
int64_t totalSize);
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
|
|
||||||
|
|
|
@ -66,12 +66,12 @@ void Xml2MetalinkProcessorTest::testParseFile() {
|
||||||
CPPUNIT_ASSERT_EQUAL(string("Linux-m68k"), entry2->os);
|
CPPUNIT_ASSERT_EQUAL(string("Linux-m68k"), entry2->os);
|
||||||
CPPUNIT_ASSERT_EQUAL(string("4c255b0ed130f5ea880f0aa061c3da0487e251cc"),
|
CPPUNIT_ASSERT_EQUAL(string("4c255b0ed130f5ea880f0aa061c3da0487e251cc"),
|
||||||
entry2->checksum->getMessageDigest());
|
entry2->checksum->getMessageDigest());
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)2, entry2->chunkChecksum->pieceHashes.size());
|
CPPUNIT_ASSERT_EQUAL((int32_t)2, entry2->chunkChecksum->countChecksum());
|
||||||
CPPUNIT_ASSERT_EQUAL(262144, entry2->chunkChecksum->pieceLength);
|
CPPUNIT_ASSERT_EQUAL(262144, entry2->chunkChecksum->getChecksumLength());
|
||||||
CPPUNIT_ASSERT_EQUAL(string("179463a88d79cbf0b1923991708aead914f26142"),
|
CPPUNIT_ASSERT_EQUAL(string("179463a88d79cbf0b1923991708aead914f26142"),
|
||||||
entry2->chunkChecksum->pieceHashes.at(0));
|
entry2->chunkChecksum->getChecksum(0));
|
||||||
CPPUNIT_ASSERT_EQUAL(string("fecf8bc9a1647505fe16746f94e97a477597dbf3"),
|
CPPUNIT_ASSERT_EQUAL(string("fecf8bc9a1647505fe16746f94e97a477597dbf3"),
|
||||||
entry2->chunkChecksum->pieceHashes.at(1));
|
entry2->chunkChecksum->getChecksum(1));
|
||||||
|
|
||||||
CPPUNIT_ASSERT(DIGEST_ALGO_SHA1 == entry2->checksum->getDigestAlgo());
|
CPPUNIT_ASSERT(DIGEST_ALGO_SHA1 == entry2->checksum->getDigestAlgo());
|
||||||
} catch(Exception* e) {
|
} catch(Exception* e) {
|
||||||
|
|
Loading…
Reference in New Issue