summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--module/CaptchaManager.py10
-rw-r--r--module/Plugin.py3
-rwxr-xr-xpyLoadCore.py10
3 files changed, 17 insertions, 6 deletions
diff --git a/module/CaptchaManager.py b/module/CaptchaManager.py
index 9fbff92a1..d6a8fd077 100644
--- a/module/CaptchaManager.py
+++ b/module/CaptchaManager.py
@@ -41,7 +41,8 @@ class CaptchaManager():
def getTask(self):
self.lock.acquire()
for task in self.tasks:
- if task.getStatus() == "waiting":
+ status = task.getStatus()
+ if status == "waiting" or status == "shared-user":
self.lock.release()
return task
self.lock.release()
@@ -100,9 +101,12 @@ class CaptchaTask():
self.status = "waiting"
self.lock.release()
- def setWatingForUser(self):
+ def setWatingForUser(self, exclusive):
self.lock.acquire()
- self.status = "user"
+ if exclusive:
+ self.status = "user"
+ else:
+ self.status = "shared-user"
self.lock.release()
def removeTask(self):
diff --git a/module/Plugin.py b/module/Plugin.py
index 59aa9c1d1..1428e6235 100644
--- a/module/Plugin.py
+++ b/module/Plugin.py
@@ -24,6 +24,7 @@ from os.path import join
from time import sleep
import sys
+from os.path import exists
from module.network.Request import Request
from os import makedirs
@@ -175,7 +176,7 @@ class Plugin():
if self.pyfile.package.data["package_name"] != (self.parent.core.config['general']['link_file']) and self.parent.core.xmlconfig.get("general", "folder_per_package", False):
self.pyfile.folder = self.pyfile.package.data["package_name"]
location = join(download_folder, self.pyfile.folder.decode(sys.getfilesystemencoding()))
- makedirs(location)
+ if not exists(location): makedirs(location)
file_path = join(location.decode(sys.getfilesystemencoding()), self.pyfile.status.filename.decode(sys.getfilesystemencoding()))
else:
file_path = join(download_folder, self.pyfile.status.filename.decode(sys.getfilesystemencoding()))
diff --git a/pyLoadCore.py b/pyLoadCore.py
index e59f8db10..16bfbbeae 100755
--- a/pyLoadCore.py
+++ b/pyLoadCore.py
@@ -718,16 +718,22 @@ class ServerMethods():
task = self.core.captchaManager.getTask()
return not task == None
- def get_captcha_task(self):
+ def get_captcha_task(self, exclusive=False):
+ self.core.lastGuiConnected = time.time()
task = self.core.captchaManager.getTask()
if task:
- task.setWatingForUser()
+ task.setWatingForUser(exclusive=exclusive)
c = task.getCaptcha()
return str(task.getID()), Binary(c[0]), str(c[1])
else:
return None, None, None
+ def get_task_status(self, tid):
+ self.core.lastGuiConnected = time.time()
+ return self.core.captchaManager.getTaskFromID(tid).getStatus()
+
def set_captcha_result(self, tid, result):
+ self.core.lastGuiConnected = time.time()
task = self.core.captchaManager.getTaskFromID(tid)
if task:
task.setResult(result)