From 13f436cd48539c2dd776dc0e6ffcd623e04c2bae Mon Sep 17 00:00:00 2001 From: j Date: Tue, 5 Nov 2013 21:02:18 +0100 Subject: [PATCH] fix seeding for peers that downloaded files --- bin/lsd | 2 +- lsd/backend.py | 4 +++- lsd/torrent.py | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/bin/lsd b/bin/lsd index 1271d7b..a6068c2 100755 --- a/bin/lsd +++ b/bin/lsd @@ -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 diff --git a/lsd/backend.py b/lsd/backend.py index 231b080..f8be7bc 100644 --- a/lsd/backend.py +++ b/lsd/backend.py @@ -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) diff --git a/lsd/torrent.py b/lsd/torrent.py index 8bbd4d9..8da3968 100644 --- a/lsd/torrent.py +++ b/lsd/torrent.py @@ -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):