fix seeding for peers that downloaded files

This commit is contained in:
j 2013-11-05 21:02:18 +01:00
parent 45293a128c
commit 13f436cd48
3 changed files with 7 additions and 4 deletions

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
# GPL 2013

View file

@ -101,7 +101,9 @@ class Site:
requested = r['data']['ids']
for sha1 in requested:
if sha1 not in self.t.handles:
self.t.add_torrent(self.t.torrent_path(sha1))
f = self.get_file(sha1)
if f:
self.t.seed(f['path'], f['sha1'])
for sha1 in self.t.handles.keys():
if sha1 not in self.t.downloads and sha1 not in requested:
self.t.remove(sha1)

View file

@ -215,9 +215,10 @@ class TorrentClient:
return True
return False
def seed(self, filename):
def seed(self, filename, sha1=None):
filename = os.path.abspath(filename)
sha1 = get_sha1(filename)
if not sha1:
sha1 = get_sha1(filename)
if not sha1 in self.handles:
torrent = self.torrent_path(sha1)
if not os.path.exists(torrent):