diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-03-13 18:48:01 +0100 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-03-13 18:48:01 +0100 |
commit | b0ab80452769af1482e679db93abd407c608a7f6 (patch) | |
tree | 64ea3210a847b810e575cc28649b2f519671e002 /module | |
parent | fixed login issue (diff) | |
download | pyload-b0ab80452769af1482e679db93abd407c608a7f6.tar.xz |
cnl fix
Diffstat (limited to 'module')
-rw-r--r-- | module/database/DatabaseBackend.py | 26 | ||||
-rw-r--r-- | module/database/FileDatabase.py | 7 | ||||
-rw-r--r-- | module/web/cnl_app.py | 6 | ||||
-rw-r--r-- | module/web/middlewares.py | 3 |
4 files changed, 27 insertions, 15 deletions
diff --git a/module/database/DatabaseBackend.py b/module/database/DatabaseBackend.py index 2bc6c0bb2..02e09b3b3 100644 --- a/module/database/DatabaseBackend.py +++ b/module/database/DatabaseBackend.py @@ -77,7 +77,22 @@ class DatabaseJob(): self.result = None self.exception = False - + + #import inspect + #self.frame = inspect.currentframe() + + def __repr__(self): + from os.path import basename + frame = self.frame.f_back + output = "" + for i in range(5): + output += "\t%s:%s, %s\n" % (basename(frame.f_code.co_filename), frame.f_lineno, frame.f_code.co_name) + frame = frame.f_back + del frame + del self.frame + + return "DataBase Job %s:%s\n%s" % (self.f.__name__, self.args[1:], output) + def processJob(self): try: self.result = self.f(*self.args, **self.kwargs) @@ -85,7 +100,8 @@ class DatabaseJob(): print "Database Error @", self.f.__name__, self.args[1:], self.kwargs, e print_exc() self.exception = e - self.done.set() + finally: + self.done.set() def wait(self): self.done.wait() @@ -96,8 +112,7 @@ class DatabaseBackend(Thread): Thread.__init__(self) self.setDaemon(True) self.core = core - - self.transactionLock = Lock() + self.jobs = Queue() self.setuplock = Event() @@ -127,18 +142,15 @@ class DatabaseBackend(Thread): while True: j = self.jobs.get() - self.transactionLock.acquire() if j == "quit": self.c.close() self.conn.close() - self.transactionLock.release() break j.processJob() if j.exception: self.conn.rollback() else: self.conn.commit() - self.transactionLock.release() @style.queue def shutdown(self): diff --git a/module/database/FileDatabase.py b/module/database/FileDatabase.py index c539bcaf6..528bf666d 100644 --- a/module/database/FileDatabase.py +++ b/module/database/FileDatabase.py @@ -59,6 +59,7 @@ class FileHandler: self.jobCache = {} self.lock = RLock() #@TODO should be a Lock w/o R + #self.lock._Verbose__verbose = True self.filecount = -1 # if an invalid value is set get current value from db self.unchanged = False #determines if any changes was made since last call @@ -473,10 +474,8 @@ class FileHandler: def updateFileInfo(self, data, pid): """ updates file info (name, size, status, url)""" ids = self.db.updateLinkInfo(data) - - for fid in ids: - e = UpdateEvent("file", fid, "collector" if not self.getFile(fid).package().queue else "queue") - self.core.pullManager.addEvent(e) + e = UpdateEvent("pack", pid, "collector" if not self.getPackage(pid).queue else "queue") + self.core.pullManager.addEvent(e) def checkPackageFinished(self, pyfile): """ checks if package is finished and calls hookmanager """ diff --git a/module/web/cnl_app.py b/module/web/cnl_app.py index 4c8b3ed4c..f46893388 100644 --- a/module/web/cnl_app.py +++ b/module/web/cnl_app.py @@ -31,7 +31,7 @@ def local_check(function): @route("/flash", method="POST") @local_check def flash(id="0"): - return "JDownloader" + return "JDownloader\r\n" @route("/flash/add", method="POST") @local_check @@ -60,7 +60,7 @@ def addcrypted(): except: return HTTPError() else: - return "success" + return "success\r\n" @route("/flash/addcrypted2", method="POST") @local_check @@ -106,7 +106,7 @@ def addcrypted2(): except: return "failed can't add" else: - return "success" + return "success\r\n" @route("/flashgot", method="POST") @local_check diff --git a/module/web/middlewares.py b/module/web/middlewares.py index 745d7e6b5..f8b2ed976 100644 --- a/module/web/middlewares.py +++ b/module/web/middlewares.py @@ -85,9 +85,10 @@ class GzipResponse(object): self.headers = headers ct = header_value(headers,'content-type') ce = header_value(headers,'content-encoding') + cl = int(header_value(headers, 'content-length')) self.compressible = False if ct and (ct.startswith('text/') or ct.startswith('application/')) \ - and 'zip' not in ct: + and 'zip' not in ct and cl > 200: self.compressible = True if ce: self.compressible = False |