2007-11-17 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

Implemented. Now -c option works fine.
	* src/DefaultPieceStorage.cc (markPiecesDone)
	* test/DefaultPieceStorageTest.cc

	Removed.
	* src/SegmentMan.{h, cc}
	(markAllPiecesDone)
	(markPieceDone)

	Synchronized po files with 
	https://translations.launchpad.net/aria2/trunk/+pots/aria2c
	* src/fr.po
	* src/ru.po
	* src/de.po
	* src/ja.po
pull/1/head
Tatsuhiro Tsujikawa 2007-11-17 13:49:36 +00:00
parent a31dbb5804
commit ab8c0aafeb
17 changed files with 1873 additions and 2127 deletions

View File

@ -1,3 +1,21 @@
2007-11-17 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Implemented. Now -c option works fine.
* src/DefaultPieceStorage.cc (markPiecesDone)
* test/DefaultPieceStorageTest.cc
Removed.
* src/SegmentMan.{h, cc}
(markAllPiecesDone)
(markPieceDone)
Synchronized po files with
https://translations.launchpad.net/aria2/trunk/+pots/aria2c
* src/fr.po
* src/ru.po
* src/de.po
* src/ja.po
2007-11-14 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added ifdef and some modifications to compile without BitTorrent,

File diff suppressed because it is too large Load Diff

BIN
po/de.gmo

Binary file not shown.

656
po/de.po

File diff suppressed because it is too large Load Diff

BIN
po/fr.gmo

Binary file not shown.

374
po/fr.po

File diff suppressed because it is too large Load Diff

BIN
po/ja.gmo

Binary file not shown.

1425
po/ja.po

File diff suppressed because it is too large Load Diff

BIN
po/nl.gmo

Binary file not shown.

348
po/nl.po

File diff suppressed because it is too large Load Diff

BIN
po/ru.gmo

Binary file not shown.

699
po/ru.po

File diff suppressed because it is too large Load Diff

View File

@ -60,7 +60,6 @@ ConsoleStatCalc::calculateStat(const RequestGroupManHandle& requestGroupMan,
if(requestGroupMan->countRequestGroup() > 0) {
RequestGroupHandle firstRequestGroup = requestGroupMan->getRequestGroup(0);
TransferStat stat = firstRequestGroup->calculateStat();
//int32_t dlSpeed = firstRequestGroup->calculateDownloadSpeed();
int32_t eta = 0;
if(firstRequestGroup->getTotalLength() > 0 && stat.getDownloadSpeed() > 0) {
eta = (firstRequestGroup->getTotalLength()-firstRequestGroup->getCompletedLength())/stat.getDownloadSpeed();

View File

@ -545,8 +545,22 @@ void DefaultPieceStorage::markAllPiecesDone()
void DefaultPieceStorage::markPiecesDone(int64_t length)
{
// TODO implement this
abort();
if(length == bitfieldMan->getTotalLength()) {
bitfieldMan->setAllBit();
} else {
int32_t numPiece = length/bitfieldMan->getBlockLength();
if(numPiece > 0) {
bitfieldMan->setBitRange(0, numPiece-1);
}
int32_t r = (length%bitfieldMan->getBlockLength())/Piece::BLOCK_LENGTH;
if(r > 0) {
PieceHandle p = new Piece(numPiece, bitfieldMan->getBlockLength(numPiece));
for(int32_t i = 0; i < r; ++i) {
p->completeBlock(i);
}
addUsedPiece(p);
}
}
}
void DefaultPieceStorage::markPieceMissing(int32_t index)

View File

@ -259,36 +259,6 @@ int32_t SegmentMan::calculateDownloadSpeed() const {
return speed;
}
void SegmentMan::markAllPiecesDone()
{
_pieceStorage->markAllPiecesDone();
}
void SegmentMan::markPieceDone(int64_t length)
{
// TODO implement this function later
/*
if(bitfield) {
if(length == bitfield->getTotalLength()) {
bitfield->setAllBit();
} else {
bitfield->clearAllBit();
int32_t numSegment = length/bitfield->getBlockLength();
int32_t remainingLength = length%bitfield->getBlockLength();
bitfield->setBitRange(0, numSegment-1);
if(remainingLength > 0) {
SegmentHandle segment = new Segment();
segment->index = numSegment;
segment->length = bitfield->getBlockLength(numSegment);
segment->segmentLength = bitfield->getBlockLength();
segment->writtenLength = remainingLength;
usedSegmentEntries.push_back(new SegmentEntry(0, segment));
}
}
}
*/
}
SegmentEntryHandle SegmentMan::getSegmentEntryByIndex(int32_t index)
{
for(SegmentEntries::const_iterator itr = usedSegmentEntries.begin();

View File

@ -184,10 +184,6 @@ public:
*/
int32_t calculateDownloadSpeed() const;
void markAllPiecesDone();
void markPieceDone(int64_t length);
int32_t countFreePieceFrom(int32_t index) const;
};

View File

@ -25,6 +25,7 @@ class DefaultPieceStorageTest:public CppUnit::TestFixture {
CPPUNIT_TEST(testGetPieceCompletedPiece);
CPPUNIT_TEST(testGetMissingPiece_fileEntry);
CPPUNIT_TEST(testCancelPiece);
CPPUNIT_TEST(testMarkPiecesDone);
CPPUNIT_TEST_SUITE_END();
private:
BtContextHandle btContext;
@ -62,6 +63,7 @@ public:
void testGetPieceCompletedPiece();
void testGetMissingPiece_fileEntry();
void testCancelPiece();
void testMarkPiecesDone();
};
@ -264,6 +266,32 @@ void DefaultPieceStorageTest::testCancelPiece()
// See the sub piece is also hibernated...
PieceHandle p2 = ps->getMissingPiece(file1);
CPPUNIT_ASSERT(!p2->getSubPiece(0).isNull());
CPPUNIT_ASSERT(!p2->getSubPiece(0).isNull());
}
void DefaultPieceStorageTest::testMarkPiecesDone()
{
int32_t pieceLength = 256*1024;
int64_t totalLength = 4*1024*1024;
MockBtContextHandle dctx = new MockBtContext();
dctx->setPieceLength(pieceLength);
dctx->setTotalLength(totalLength);
DefaultPieceStorage ps(dctx, option);
ps.markPiecesDone(pieceLength*10+16*1024*2+1);
for(int32_t i = 0; i < 10; ++i) {
CPPUNIT_ASSERT(ps.hasPiece(i));
}
for(int32_t i = 10; i < (totalLength+pieceLength-1)/pieceLength; ++i) {
CPPUNIT_ASSERT(!ps.hasPiece(i));
}
CPPUNIT_ASSERT_EQUAL((int64_t)pieceLength*10+16*1024*2, ps.getCompletedLength());
ps.markPiecesDone(totalLength);
for(int32_t i = 0; i < (totalLength+pieceLength-1)/pieceLength; ++i) {
CPPUNIT_ASSERT(ps.hasPiece(i));
}
}