r380 - /debtorrent/trunk/uniquely.py

camrdale-guest at users.alioth.debian.org camrdale-guest at users.alioth.debian.org
Thu Jun 19 21:49:57 UTC 2008


Author: camrdale-guest
Date: Thu Jun 19 21:49:57 2008
New Revision: 380

URL: http://svn.debian.org/wsvn/debtorrent/?sc=1&rev=380
Log:
Reset uniquely's torrents when they grow too big.

Modified:
    debtorrent/trunk/uniquely.py

Modified: debtorrent/trunk/uniquely.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/uniquely.py?rev=380&op=diff
==============================================================================
--- debtorrent/trunk/uniquely.py (original)
+++ debtorrent/trunk/uniquely.py Thu Jun 19 21:49:57 2008
@@ -31,6 +31,9 @@
 HEADER_ORDER = ["Torrent", "Infohash", "InfohashArchs", "OriginalDate", "Date",
                 "PieceSize", "NextPiece", "OriginalPieces", "Codename", "Suite",
                 "Component", "Architecture", "Tracker", "TorrentHashFields"]
+
+# The maximum increase in the size of the torrent before it is reset
+MAX_SIZE_INCREASE = 2.0
 
 class Torrent(deb822._multivalued):
     """For reading piece numbers from a unique piece number torrent file."""
@@ -151,8 +154,10 @@
         sha1.update(headers[header])
     new_hash = sha1.hexdigest()
     
-    # Check if the hash has changed
-    if headers.get("Torrent", "") == new_hash:
+    # Check if the hash has changed or the torrent is too big
+    if (headers.get("Torrent", "") == new_hash and
+        int(headers.get("NextPiece")) < 
+        int(headers.get("OriginalPieces", "0"))*MAX_SIZE_INCREASE):
         return False
     else:
         # If it has, then reset the torrent to create a new one




More information about the Debtorrent-commits mailing list