From c02a81a7bdee7628942d43add75b0a2131c87ba9 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sat, 18 Jan 2014 20:27:03 +0100 Subject: additional fix #3 --- pyload/DownloadManager.py | 7 +++++-- pyload/threads/DecrypterThread.py | 10 +++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/pyload/DownloadManager.py b/pyload/DownloadManager.py index 6345f9519..452be93e1 100644 --- a/pyload/DownloadManager.py +++ b/pyload/DownloadManager.py @@ -63,11 +63,13 @@ class DownloadManager: @lock def done(self, thread): """ Switch thread from working to free state """ - self.working.remove(thread) # only download threads will be re-used if isinstance(thread, DownloadThread): + self.working.remove(thread) self.free.append(thread) thread.isWorking.clear() + elif isinstance(thread, DecrypterThread): + self.decrypter.remove(thread) @lock def stop(self, thread): @@ -96,7 +98,8 @@ class DownloadManager: @lock def startDecrypterThread(self, info): """ Start decrypting of entered data, all links in one package are accumulated to one thread.""" - self.decrypter.append(DecrypterThread(self, [(info.download.plugin, info.download.url)], info.package)) + self.decrypter.append(DecrypterThread(self, [(info.download.plugin, info.download.url)], + info.fid, info.package, info.owner)) @read_lock def activeDownloads(self, uid=None): diff --git a/pyload/threads/DecrypterThread.py b/pyload/threads/DecrypterThread.py index 2e4560094..76bd9fce0 100644 --- a/pyload/threads/DecrypterThread.py +++ b/pyload/threads/DecrypterThread.py @@ -14,14 +14,16 @@ from BaseThread import BaseThread class DecrypterThread(BaseThread): """thread for decrypting""" - def __init__(self, manager, data, pid): - # TODO: owner - BaseThread.__init__(self, manager) + def __init__(self, manager, data, fid, pid, owner): + BaseThread.__init__(self, manager, owner) # [... (plugin, url) ...] self.data = data + self.fid = fid self.pid = pid # holds the progress, while running self.progress = None + # holds if an error happened + self.error = False self.start() @@ -42,6 +44,7 @@ class DecrypterThread(BaseThread): for p in packages: self.m.core.api.addPackage(p.name, p.getURLs(), pack.password) + self.m.core.api.files.setDownloadStatus(self.fid, "finished" if not self.error else "failed") self.m.done(self) def decrypt(self, plugin_map, password=None, err=False): @@ -82,6 +85,7 @@ class DecrypterThread(BaseThread): except Exception, e: plugin.logError(_("Decrypting failed"), e) + self.error = True # generate error linkStatus if err: plugin_result.extend(LinkStatus(url, url, -1, DS.Failed, name) for url in urls) -- cgit v1.2.3