Bläddra i källkod

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

	Eliminated g++-4.2 warning
	* src/DownloadHandlerConstants.{h, cc}
	* src/Util.cc
	* test/MetaFileUtilTest.cc
	* test/PStringBuildVisitorTest.cc
	
	Fixed bug: --check-integrity dones't work for multi file 
torrent.
	* src/RequestGroup.cc
	* src/BtCheckIntegrityEntry.cc
Tatsuhiro Tsujikawa 18 år sedan
förälder
incheckning
4a59e5899a

+ 12 - 0
ChangeLog

@@ -1,3 +1,15 @@
+2007-11-29  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
+
+	Eliminated g++-4.2 warning
+	* src/DownloadHandlerConstants.{h, cc}
+	* src/Util.cc
+	* test/MetaFileUtilTest.cc
+	* test/PStringBuildVisitorTest.cc
+	
+	Fixed bug: --check-integrity dones't work for multi file torrent.
+	* src/RequestGroup.cc
+	* src/BtCheckIntegrityEntry.cc
+	
 2007-11-29  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 
 	Fixed a2io.h

+ 2 - 0
src/BtCheckIntegrityEntry.cc

@@ -40,6 +40,7 @@
 #include "PieceStorage.h"
 #include "DownloadEngine.h"
 #include "FileAllocationMan.h"
+#include "DiskAdaptor.h"
 
 BtCheckIntegrityEntry::BtCheckIntegrityEntry(RequestGroup* requestGroup):
   PieceHashCheckIntegrityEntry(requestGroup, 0) {}
@@ -60,6 +61,7 @@ Commands BtCheckIntegrityEntry::onDownloadIncomplete(DownloadEngine* e)
 
 Commands BtCheckIntegrityEntry::onDownloadFinished(DownloadEngine* e)
 {
+  _requestGroup->getPieceStorage()->getDiskAdaptor()->onDownloadComplete();
   // TODO Currently,when all the checksums
   // 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

+ 4 - 4
src/DownloadHandlerConstants.cc

@@ -34,15 +34,15 @@
 /* copyright --> */
 #include "DownloadHandlerConstants.h"
 
-char* DownloadHandlerConstants::METALINK_EXTENSIONS[] = { ".metalink" };
+const char* DownloadHandlerConstants::METALINK_EXTENSIONS[] = { ".metalink" };
 
-char* DownloadHandlerConstants::METALINK_CONTENT_TYPES[] = {
+const char* DownloadHandlerConstants::METALINK_CONTENT_TYPES[] = {
   "application/metalink+xml"
 };
 
-char* DownloadHandlerConstants::BT_EXTENSIONS[] = { ".torrent" };
+const char* DownloadHandlerConstants::BT_EXTENSIONS[] = { ".torrent" };
 
-char* DownloadHandlerConstants::BT_CONTENT_TYPES[] = {
+const char* DownloadHandlerConstants::BT_CONTENT_TYPES[] = {
   "application/x-bittorrent"
 };
 

+ 4 - 4
src/DownloadHandlerConstants.h

@@ -41,19 +41,19 @@
 class DownloadHandlerConstants
 {
 public:
-  static char* METALINK_EXTENSIONS[];
+  static const char* METALINK_EXTENSIONS[];
 
   static Strings getMetalinkExtensions();
 
-  static char* METALINK_CONTENT_TYPES[];
+  static const char* METALINK_CONTENT_TYPES[];
 
   static Strings getMetalinkContentTypes();
 
-  static char* BT_EXTENSIONS[];
+  static const char* BT_EXTENSIONS[];
 
   static Strings getBtExtensions();
 
-  static char* BT_CONTENT_TYPES[];
+  static const char* BT_CONTENT_TYPES[];
 
   static Strings getBtContentTypes();
 };

+ 1 - 2
src/RequestGroup.cc

@@ -237,8 +237,7 @@ Commands RequestGroup::createInitialCommand(DownloadEngine* e)
 Commands RequestGroup::processCheckIntegrityEntry(const CheckIntegrityEntryHandle& entry, DownloadEngine* e)
 {
 #ifdef ENABLE_MESSAGE_DIGEST
-  if(//File(getFilePath()).size() > 0 &&
-     e->option->get(PREF_CHECK_INTEGRITY) == V_TRUE &&
+  if(e->option->get(PREF_CHECK_INTEGRITY) == V_TRUE &&
      entry->isValidationReady()) {
     entry->initValidator();
     CheckIntegrityCommand* command =

+ 1 - 1
src/Util.cc

@@ -581,7 +581,7 @@ int32_t Util::countBit(uint32_t n) {
 }
 
 string Util::randomAlpha(int32_t length, const RandomizerHandle& randomizer) {
-  static char *random_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+  static const char *random_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
   string str;
   for(int32_t i = 0; i < length; i++) {
     int32_t index = randomizer->getRandomNumber(strlen(random_chars));

+ 4 - 4
test/MetaFileUtilTest.cc

@@ -35,7 +35,7 @@ void MetaFileUtilTest::testParseMetaFile() {
 
 void MetaFileUtilTest::testBdecoding() {
   try {
-    char* str = "5:abcd";
+    const char* str = "5:abcd";
     MetaEntry* entry = MetaFileUtil::bdecoding(str, strlen(str));
     CPPUNIT_FAIL("DlAbortEx exception must be thrown.");
   } catch(DlAbortEx* ex) {
@@ -45,7 +45,7 @@ void MetaFileUtilTest::testBdecoding() {
   }
 
   try {
-    char* str = "i1234";
+    const char* str = "i1234";
     MetaEntry* entry = MetaFileUtil::bdecoding(str, strlen(str));
     CPPUNIT_FAIL("DlAbortEx exception must be thrown.");
   } catch(DlAbortEx* ex) {
@@ -55,7 +55,7 @@ void MetaFileUtilTest::testBdecoding() {
   }
 
   try {
-    char* str = "5abcd";
+    const char* str = "5abcd";
     MetaEntry* entry = MetaFileUtil::bdecoding(str, strlen(str));
     CPPUNIT_FAIL("DlAbortEx exception must be thrown.");
   } catch(DlAbortEx* ex) {
@@ -65,7 +65,7 @@ void MetaFileUtilTest::testBdecoding() {
   }
 
   try {
-    char* str = "d";
+    const char* str = "d";
     MetaEntry* entry = MetaFileUtil::bdecoding(str, strlen(str));
     CPPUNIT_FAIL("DlAbortEx exception must be thrown.");
   } catch(DlAbortEx* ex) {

+ 2 - 2
test/PStringBuildVisitorTest.cc

@@ -30,7 +30,7 @@ void PStringBuildVisitorTest::testVisit_select()
 {
   PStringSegmentHandle segment1 = new PStringSegment("/tango");
 
-  char* select1data[] = { "alpha", "bravo", "charlie" };
+  const char* select1data[] = { "alpha", "bravo", "charlie" };
   
   PStringSelectHandle select1 =
     new PStringSelect(Strings(&select1data[0], &select1data[3]), segment1);
@@ -66,7 +66,7 @@ void PStringBuildVisitorTest::testVisit_select_numLoop()
 {
   PStringSegmentHandle segment1 = new PStringSegment("/tango");
 
-  char* select1data[] = { "alpha", "bravo", "charlie" };
+  const char* select1data[] = { "alpha", "bravo", "charlie" };
   
   PStringSelectHandle select1 =
     new PStringSelect(Strings(&select1data[0], &select1data[3]), segment1);