r321 - in /apt-transport-debtorrent/trunk: debian/changelog debtorrent.cc debtorrent.h

camrdale-guest at users.alioth.debian.org camrdale-guest at users.alioth.debian.org
Wed Nov 7 00:09:32 UTC 2007


Author: camrdale-guest
Date: Wed Nov  7 00:09:32 2007
New Revision: 321

URL: http://svn.debian.org/wsvn/debtorrent/?sc=1&rev=321
Log:
  - Send general status updates to apt (103) from DebTorrent

Modified:
    apt-transport-debtorrent/trunk/debian/changelog
    apt-transport-debtorrent/trunk/debtorrent.cc
    apt-transport-debtorrent/trunk/debtorrent.h

Modified: apt-transport-debtorrent/trunk/debian/changelog
URL: http://svn.debian.org/wsvn/debtorrent/apt-transport-debtorrent/trunk/debian/changelog?rev=321&op=diff
==============================================================================
--- apt-transport-debtorrent/trunk/debian/changelog (original)
+++ apt-transport-debtorrent/trunk/debian/changelog Wed Nov  7 00:09:32 2007
@@ -2,6 +2,7 @@
 
   * Upgrade transport version to 0.2
     - Create sparse files based on status messages (102) from DebTorrent
+    - Send general status updates to apt (103) from DebTorrent
   * Remove support for Range headers as they may confuse the
     sparse file allocation
 

Modified: apt-transport-debtorrent/trunk/debtorrent.cc
URL: http://svn.debian.org/wsvn/debtorrent/apt-transport-debtorrent/trunk/debtorrent.cc?rev=321&op=diff
==============================================================================
--- apt-transport-debtorrent/trunk/debtorrent.cc (original)
+++ apt-transport-debtorrent/trunk/debtorrent.cc Wed Nov  7 00:09:32 2007
@@ -353,7 +353,7 @@
 {
    State = Header;
    
-   Owner->Status("Waiting for headers");
+   // Owner->Status("Waiting for headers");
 
    Major = 0; 
    Minor = 0; 
@@ -363,6 +363,7 @@
    Encoding = Closes;
    HaveContent = false;
    time(&Date);
+   Message[0] = '\0';
 
    do
    {
@@ -385,6 +386,20 @@
       // 100 Continue is a Nop...
       if (Result == 100)
 	 continue;
+      
+      // 103 Status Update for apt
+      if (Result == 103)
+      {
+	 Owner->Status(Message);
+	 if (Debug == true)
+	 {
+	    char Buf[1000];
+	    sprintf(Buf,"StatusMessage: %s\n", Message);
+	    string Req = Buf;
+	    cerr << Req << endl;
+	 }
+	 continue;
+      }
       
       // Tidy up the connection persistance state.
       if (Encoding == Closes && HaveContent == true)
@@ -538,6 +553,14 @@
 	 return _error->Error("The DebTorrent client sent an invalid Pieces-Downloaded header");
       if ((unsigned)StartPos > Size)
 	 return _error->Error("This DebTorrent client has broken Pieces-Downloaded support");
+      return true;
+   }
+   
+   // The new Message header indicating the DebTorrent client's current status      
+   if (stringcasecmp(Tag,"Message:") == 0)
+   {
+      if (sscanf(Val.c_str(),"%[^\n]",Message) != 1)
+	 return _error->Error("The DebTorrent client sent an invalid Message header");
       return true;
    }
    
@@ -1222,6 +1245,13 @@
 	    // Ok, the file is Open
 	    case 0:
 	    {
+	       // Make sure to send the URIStart first
+	       if (Queue->IndexFile == false)
+	       {
+		  URIStart(Res);
+		  Queue->IndexFile = true;
+	       }
+
 	       // Run the data
 	       bool Result =  Server->RunData();
 

Modified: apt-transport-debtorrent/trunk/debtorrent.h
URL: http://svn.debian.org/wsvn/debtorrent/apt-transport-debtorrent/trunk/debtorrent.h?rev=321&op=diff
==============================================================================
--- apt-transport-debtorrent/trunk/debtorrent.h (original)
+++ apt-transport-debtorrent/trunk/debtorrent.h Wed Nov  7 00:09:32 2007
@@ -101,6 +101,7 @@
    enum {Chunked,Stream,Closes} Encoding;
    enum {Header, Data} State;
    bool Persistent;
+   char Message[MAXLEN];
    
    // This is a Persistent attribute of the server itself.
    bool Pipeline;




More information about the Debtorrent-commits mailing list