r236 - in /debtorrent/branches/unique: DebTorrent/BT1/AptListener.py DebTorrent/BT1/StorageWrapper.py hippy.py

camrdale-guest at users.alioth.debian.org camrdale-guest at users.alioth.debian.org
Tue Aug 14 05:14:24 UTC 2007


Author: camrdale-guest
Date: Tue Aug 14 05:14:24 2007
New Revision: 236

URL: http://svn.debian.org/wsvn/debtorrent/?sc=1&rev=236
Log:
Various minor fixes.

Modified:
    debtorrent/branches/unique/DebTorrent/BT1/AptListener.py
    debtorrent/branches/unique/DebTorrent/BT1/StorageWrapper.py
    debtorrent/branches/unique/hippy.py

Modified: debtorrent/branches/unique/DebTorrent/BT1/AptListener.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/branches/unique/DebTorrent/BT1/AptListener.py?rev=236&op=diff
==============================================================================
--- debtorrent/branches/unique/DebTorrent/BT1/AptListener.py (original)
+++ debtorrent/branches/unique/DebTorrent/BT1/AptListener.py Tue Aug 14 05:14:24 2007
@@ -412,6 +412,11 @@
             logger.warning('Unable to find the file in any torrents: '+'/'.join(path))
             return (404, 'Not Found', {'Server': VERSION, 'Content-Type': 'text/plain', 'Pragma': 'no-cache'}, alas)
 
+        # Check if the torrent is running
+        if d.doneflag.isSet():
+            logger.error('The needed torrent is not running')
+            return (404, 'Not Found', {'Server': VERSION, 'Content-Type': 'text/plain', 'Pragma': 'no-cache'}, alas)
+        
         # Check if the file has already been downloaded
         data = ''
         pieces_needed = []
@@ -425,11 +430,6 @@
         if not pieces_needed:
             return (200, 'OK', {'Server': VERSION, 'Content-Type': 'text/plain'}, data)
 
-        # Check if the torrent is running/not paused
-        if d.doneflag.isSet():
-            logger.error('The needed torrent is not running')
-            return (404, 'Not Found', {'Server': VERSION, 'Content-Type': 'text/plain', 'Pragma': 'no-cache'}, alas)
-        
         if not d.unpauseflag.isSet():
             d.Unpause()
         

Modified: debtorrent/branches/unique/DebTorrent/BT1/StorageWrapper.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/branches/unique/DebTorrent/BT1/StorageWrapper.py?rev=236&op=diff
==============================================================================
--- debtorrent/branches/unique/DebTorrent/BT1/StorageWrapper.py (original)
+++ debtorrent/branches/unique/DebTorrent/BT1/StorageWrapper.py Tue Aug 14 05:14:24 2007
@@ -406,7 +406,7 @@
         self.bgalloc_active = False
         self.total_length = storage.get_total_length()
         self.amount_left = self.total_length
-        if self.total_length <= self.datalength - self.piece_sizes[-1]:
+        if self.total_length < self.datalength:
             raise ValueError, 'bad data in responsefile - total too small'
         if self.total_length > self.datalength:
             raise ValueError, 'bad data in responsefile - total too big'

Modified: debtorrent/branches/unique/hippy.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/branches/unique/hippy.py?rev=236&op=diff
==============================================================================
--- debtorrent/branches/unique/hippy.py (original)
+++ debtorrent/branches/unique/hippy.py Tue Aug 14 05:14:24 2007
@@ -117,9 +117,11 @@
         cache_value += struct.pack(">i", length) + binascii.a2b_hex(hash)
     return cache_value
 
-def sub_piece(filename):
+def sub_piece(cache, filename):
     """Calculate and print the sub-pieces for a single file.
     
+    @type cache: C{bsddb.BTree}
+    @param cache: an already opened bDB b-tree
     @type filename: C{String}
     @param filename: the file to calculate sub pieces for
     
@@ -168,7 +170,7 @@
 
     # Read files to sub-piece from standard in
     for filename in sys.stdin:
-        sub_piece(filename)
+        sub_piece(cache, filename)
 
     # Close the cache file
     cache.sync()




More information about the Debtorrent-commits mailing list