From 3c061095e91812e2e80caeb5c976efc2b8cf91cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joel=20K=C3=A5berg?= Date: Sat, 9 Nov 2013 18:33:21 +0100 Subject: [PATCH] remove only files, not folder (or in worst case the download clients root folder and anything in it) --- couchpotato/core/downloaders/rtorrent/main.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/couchpotato/core/downloaders/rtorrent/main.py b/couchpotato/core/downloaders/rtorrent/main.py index 67df20a6..c69d3003 100755 --- a/couchpotato/core/downloaders/rtorrent/main.py +++ b/couchpotato/core/downloaders/rtorrent/main.py @@ -8,7 +8,6 @@ from hashlib import sha1 from rtorrent import RTorrent from rtorrent.err import MethodError import os -import shutil log = CPLog(__name__) @@ -202,16 +201,20 @@ class rTorrent(Downloader): def processComplete(self, release_download, delete_files): log.debug('Requesting rTorrent to remove the torrent %s%s.', (release_download['name'], ' and cleanup the downloaded files' if delete_files else '')) + if not self.connect(): return False torrent = self.rt.find_torrent(release_download['id']) + if torrent is None: return False + for file_item in torrent.get_files(): + os.unlink(os.path.join(torrent.directory, file_item.path) + + # Need a proper solution to remove the torrent folder, if the torrent has one; THE RPC DOESN'T SUPPORT IT! + torrent.erase() # just removes the torrent, doesn't delete data - if delete_files: - shutil.rmtree(release_download['folder'], True) - return True