r111 - in /debtorrent/trunk/DebTorrent: BT1/AptListener.py launchmanycore.py
camrdale-guest at users.alioth.debian.org
camrdale-guest at users.alioth.debian.org
Fri Jun 15 02:48:45 UTC 2007
Author: camrdale-guest
Date: Fri Jun 15 02:48:45 2007
New Revision: 111
URL: http://svn.debian.org/wsvn/debtorrent/?sc=1&rev=111
Log:
When loading the same torrent, just add it's info to the running one.
Modified:
debtorrent/trunk/DebTorrent/BT1/AptListener.py
debtorrent/trunk/DebTorrent/launchmanycore.py
Modified: debtorrent/trunk/DebTorrent/BT1/AptListener.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/DebTorrent/BT1/AptListener.py?rev=111&op=diff
==============================================================================
--- debtorrent/trunk/DebTorrent/BT1/AptListener.py (original)
+++ debtorrent/trunk/DebTorrent/BT1/AptListener.py Fri Jun 15 02:48:45 2007
@@ -671,10 +671,6 @@
infohash = sha(bencode(response['info'])).digest()
- # TODO: add mirror data and start deb_mirror downloader to running torrent
- if self.handler.has_torrent(infohash):
- return
-
a = {}
a['path'] = '/'.join(path)
a['file'] = name
Modified: debtorrent/trunk/DebTorrent/launchmanycore.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/DebTorrent/launchmanycore.py?rev=111&op=diff
==============================================================================
--- debtorrent/trunk/DebTorrent/launchmanycore.py (original)
+++ debtorrent/trunk/DebTorrent/launchmanycore.py Fri Jun 15 02:48:45 2007
@@ -513,7 +513,7 @@
del self.downloads[hash]
def add(self, hash, data, save_cache = True):
- """Start a new torrent running.
+ """Start a new torrent running, or add the data to the current one.
@type hash: C{string}
@param hash: the info hash of the torrent
@@ -524,20 +524,35 @@
"""
+ # If the torrent is already cached, just add new deb_mirrors to it
+ new_debmirrors = []
+ if hash in self.torrent_cache:
+ for u in data['metainfo'].get('deb_mirrors', []):
+ if u not in self.torrent_cache[hash]['metainfo'].get('deb_mirrors', []):
+ new_debmirrors.append(u)
+ self.torrent_cache[hash]['metainfo'].setdefault('deb_mirrors', []).append(u)
+ else:
+ self.torrent_cache[hash] = data
+
+ # Save the new torrent file to the cache
if save_cache:
- self.configdir.writeTorrent(data['metainfo'], hash)
- self.torrent_cache[hash] = data
- c = self.counter
- self.counter += 1
- x = ''
- for i in xrange(3):
- x = mapbase64[c & 0x3F]+x
- c >>= 6
- peer_id = createPeerID(x)
- d = SingleDownload(self, hash, data['metainfo'], self.config, peer_id)
- self.torrent_list.append(hash)
- self.downloads[hash] = d
- d.start()
+ self.configdir.writeTorrent(self.torrent_cache[hash], hash)
+
+ if hash in self.torrent_list:
+ for u in new_debmirrors:
+ self.downloads[hash].d.httpdownloader.make_download(u)
+ else:
+ c = self.counter
+ self.counter += 1
+ x = ''
+ for i in xrange(3):
+ x = mapbase64[c & 0x3F]+x
+ c >>= 6
+ peer_id = createPeerID(x)
+ d = SingleDownload(self, hash, data['metainfo'], self.config, peer_id)
+ self.torrent_list.append(hash)
+ self.downloads[hash] = d
+ d.start()
def saveAs(self, hash, name, saveas, isdir):
More information about the Debtorrent-commits
mailing list