summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-10-16 14:28:34 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-10-16 14:28:34 +0200
commitaade6e6239438b582620cc52b46c63cdde880752 (patch)
tree63d600bce110fde7c2d2d384e2ce5ffc47e363f9 /module
parentclosed #131 (diff)
downloadpyload-aade6e6239438b582620cc52b46c63cdde880752.tar.xz
fixed decrypting files when dl slots are full
Diffstat (limited to 'module')
-rw-r--r--module/FileDatabase.py32
-rw-r--r--module/ThreadManager.py9
-rw-r--r--module/pyunrar.py2
3 files changed, 37 insertions, 6 deletions
diff --git a/module/FileDatabase.py b/module/FileDatabase.py
index 373e4e571..baf580469 100644
--- a/module/FileDatabase.py
+++ b/module/FileDatabase.py
@@ -357,7 +357,22 @@ class FileHandler:
#pyfile = self.getFile(self.jobCache[occ].pop())
return pyfile
- #----------------------------------------------------------------------
+ @lock
+ def getDecryptJob(self):
+ """return job for decrypting"""
+ if self.jobCache.has_key("decrypt"):
+ return None
+
+ plugins = self.core.pluginManager.crypterPlugins.keys() + self.core.pluginManager.containerPlugins.keys()
+ plugins = tuple(plugins)
+
+ jobs = self.db.getPluginJob(plugins)
+ if jobs:
+ return self.getFile(jobs[0])
+ else:
+ self.jobCache["decrypt"] = "empty"
+ return None
+
def getFileCount(self):
"""returns number of files"""
@@ -875,7 +890,7 @@ class FileDatabaseBackend(Thread):
@queue
def getJob(self, occ):
- """return pyfile instance, which is suitable for download and dont use a occupied plugin"""
+ """return pyfile ids, which are suitable for download and dont use a occupied plugin"""
#@TODO improve this hardcoded method
pre = "('DLC', 'LinkList', 'SerienjunkiesOrg', 'CCF', 'RSDF')" #plugins which are processed in collector
@@ -892,14 +907,23 @@ class FileDatabaseBackend(Thread):
self.c.execute(cmd) # very bad!
return [x[0] for x in self.c]
-
+
+ @queue
+ def getPluginJob(self, plugins):
+ """returns pyfile ids with suited plugins"""
+ cmd = "SELECT l.id FROM links as l INNER JOIN packages as p ON l.package=p.id WHERE l.plugin IN %s AND l.status IN (2,3,6,14) ORDER BY p.priority DESC, p.packageorder ASC, l.linkorder ASC LIMIT 5" % plugins
+
+ self.c.execute(cmd) # very bad!
+
+ return [x[0] for x in self.c]
+
@queue
def getUnfinished(self, pid):
"""return list of max length 3 ids with pyfiles in package not finished or processed"""
self.c.execute("SELECT id FROM links WHERE package=? AND status NOT IN (0, 13) LIMIT 3", (str(pid),))
return [r[0] for r in self.c]
-
+
class PyFile():
def __init__(self, manager, id, url, name, size, status, error, pluginname, package, order):
diff --git a/module/ThreadManager.py b/module/ThreadManager.py
index f9a306c78..f46f816e4 100644
--- a/module/ThreadManager.py
+++ b/module/ThreadManager.py
@@ -209,11 +209,18 @@ class ThreadManager:
thread.put(job)
else:
- #put job back
+ #put job back
if not self.core.files.jobCache.has_key(occ):
self.core.files.jobCache[occ] = []
self.core.files.jobCache[occ].append(job.id)
+ #check for decrypt jobs
+ job = self.core.files.getDecryptJob()
+ if job:
+ job.initPlugin()
+ thread = PluginThread.DecrypterThread(self, job)
+
+
else:
thread = PluginThread.DecrypterThread(self, job)
diff --git a/module/pyunrar.py b/module/pyunrar.py
index 0cb6d6d2e..01dc40a75 100644
--- a/module/pyunrar.py
+++ b/module/pyunrar.py
@@ -128,7 +128,7 @@ class Unrar():
args.append("-p-")
args.append(f)
p = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE, bufsize=-1)
- ret = p.wait()
+ ret = p.wait() #@TODO blocks for big archives with many files
if ret == 3:
self.headerEncrypted = True
raise WrongPasswordError()