Tatsuhiro Tsujikawa 19 년 전
부모
커밋
27d392d5f2
7개의 변경된 파일21개의 추가작업 그리고 25개의 파일을 삭제
  1. 6 0
      ChangeLog
  2. 3 1
      TODO
  3. 2 2
      src/DlAbortEx.h
  4. 1 1
      src/DlRetryEx.h
  5. 1 7
      src/HttpResponseCommand.cc
  6. 6 12
      src/main.cc
  7. 2 2
      src/message.h

+ 6 - 0
ChangeLog

@@ -1,3 +1,9 @@
+2006-02-22  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
+
+	* main.cc: -s option now affects all URLs in command-line arguemtns.
+	* HttpResponseCommand.cc: Fixed bug that segment file is not loaded.
+	* message.h: Change file size related %d to %lld.
+
 2006-02-21  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 
 	* FtpInitiateConnectionCommand.{h,cc}:

+ 3 - 1
TODO

@@ -4,4 +4,6 @@
 * Add SSL client cert support
 * Better HTTP status handling
 * Download files listed in a specifed file.
-* check MD5 checksum
+* check MD5 checksum
+* Apply "split longest remianing time first" algorithm to SegmentMan.
+* split algorithm must be separate class.

+ 2 - 2
src/DlAbortEx.h

@@ -26,10 +26,10 @@
 class DlAbortEx:public Exception {
 public:
   DlAbortEx():Exception() {}
-  DlAbortEx(string msg, ...):Exception() {
+  DlAbortEx(const char* msg, ...):Exception() {
     va_list ap;
     va_start(ap, msg);
-    setMsg(msg, ap);
+    setMsg(string(msg), ap);
     va_end(ap);
   }
 };

+ 1 - 1
src/DlRetryEx.h

@@ -26,7 +26,7 @@
 class DlRetryEx:public Exception {
 public:
   DlRetryEx():Exception() {}
-  DlRetryEx(string msg, ...):Exception() {
+  DlRetryEx(const char* msg, ...):Exception() {
     va_list ap;
     va_start(ap, msg);
     setMsg(msg, ap);

+ 1 - 7
src/HttpResponseCommand.cc

@@ -68,10 +68,6 @@ bool HttpResponseCommand::executeInternal(Segment seg) {
     if(req->getFile() != e->segmentMan->filename) {
       throw new DlAbortEx(EX_FILENAME_MISMATCH, req->getFile().c_str(), e->segmentMan->filename.c_str());
     }
-    long long int size = headers.getFirstAsLLInt("Content-Length");
-    if(e->segmentMan->totalSize != size) {
-      throw new DlAbortEx(EX_SIZE_MISMATCH, e->segmentMan->totalSize, size);
-    }
     createHttpDownloadCommand();
     return true;
   }
@@ -102,10 +98,8 @@ bool HttpResponseCommand::handleDefaultEncoding(const HttpHeader& headers) {
   bool segFileExists = e->segmentMan->segmentFileExists();
   e->segmentMan->downloadStarted = true;
   if(segFileExists) {
+    e->segmentMan->load();
     e->diskWriter->openExistingFile(e->segmentMan->getFilePath());
-    if(e->segmentMan->totalSize != size) {
-      return new DlAbortEx(EX_SIZE_MISMATCH, e->segmentMan->totalSize, size);
-    }
     // send request again to the server with Range header
     return prepareForRetry(0);
   } else {

+ 6 - 12
src/main.cc

@@ -107,8 +107,8 @@ void showUsage() {
   cout << "                              log is written to stdout." << endl;
   cout << " -D, --daemon                 Run as daemon." << endl;
   cout << " -s, --split=N                Download a file using s connections. s must be" << endl;
-  cout << "                              between 1 and 5. If this option is specified the" << endl;
-  cout << "                              first URL is used, and the other URLs are ignored." << endl;
+  cout << "                              between 1 and 5. This option affects all URLs." << endl;
+  cout << "                              Thus, aria2 connects to each URL with N connections." << endl;
   cout << " --retry-wait=SEC             Set amount of time in second between requests" << endl;
   cout << "                              for errors. Specify a value between 0 and 60." << endl;
   cout << "                              Default: 5" << endl;
@@ -163,7 +163,7 @@ int main(int argc, char* argv[]) {
   string logfile;
   string dir;
   string ufilename;
-  int split = 0;
+  int split = 1;
   bool daemonMode = false;
   string referer;
 
@@ -393,7 +393,6 @@ int main(int argc, char* argv[]) {
   } else {
     logger = new SimpleLogger("/dev/null");
   }
-
   e = new DownloadEngine();
   e->logger = logger;
   e->option = op;
@@ -404,16 +403,11 @@ int main(int argc, char* argv[]) {
   e->segmentMan->logger = logger;
   e->segmentMan->option = op;
   vector<Request*> requests;
-  if(split > 0) {
-    for(int i = 1; i <= split; i++) {
-      addCommand(i, argv[optind], referer, requests);
-    }
-  } else {
-    for(int i = 1; optind < argc; i++) {
-      addCommand(i, argv[optind++], referer, requests); 
+  for(int i = 1; optind+i-1 < argc; i++) {
+    for(int s = 1; s <= split; s++) {
+      addCommand(split*(i-1)+s, argv[optind+i-1], referer, requests); 
     }
   }
-
   struct sigaction sigact;
   sigact.sa_handler = handler;
   sigact.sa_flags = 0;

+ 2 - 2
src/message.h

@@ -52,9 +52,9 @@
 #define EX_CONNECTION_FAILED "Connection failed."
 #define EX_FILENAME_MISMATCH "The requested filename and the previously registered one are not same. %s != %s"
 #define EX_BAD_STATUS "The response status is not successful. status = %d"
-#define EX_TOO_LARGE_FILE "Too large file size. size = %d"
+#define EX_TOO_LARGE_FILE "Too large file size. size = %lld"
 #define EX_TRANSFER_ENCODING_NOT_SUPPORTED "Transfer encoding %s is not supported."
 #define EX_SSL_INIT_FAILURE "SSL initialization failed."
-#define EX_SIZE_MISMATCH "Size mismatch %d != %d"
+#define EX_SIZE_MISMATCH "Size mismatch %lld != %lld"
 
 #endif // _D_MESSAGE_H_