diff options
| -rw-r--r-- | module/FileDatabase.py | 39 | ||||
| -rw-r--r-- | module/PluginThread.py | 3 | ||||
| -rw-r--r-- | module/plugins/hooks/HotFolder.py | 2 | 
3 files changed, 39 insertions, 5 deletions
| diff --git a/module/FileDatabase.py b/module/FileDatabase.py index 8a334ea58..bbf02387e 100644 --- a/module/FileDatabase.py +++ b/module/FileDatabase.py @@ -47,7 +47,7 @@ statusMap = {      "custom":      11,      "downloading": 12,      "processing":  13, -    "unknow":      14 +    "unknown":     14  }  def formatSize(size): @@ -424,6 +424,29 @@ class FileHandler:          self.db.updateLinkInfo(data)          #@TODO package update event +         +    def checkPackageFinished(self, pyfile): +        """ checks if package is finished and calls hookmanager """ +         +        ids = self.db.getUnfinished(pyfile.packageid) +        if not ids or (pyfile.id in ids and len(ids) == 1): +            if not pyfile.package().setFinished: +                self.core.log.info("Package finished: %s" % pyfile.package().name) +                self.core.hookManager.packageFinished(pyfile.package()) +                pyfile.package().setFinished = True +                 +                 +    def reCheckPackage(self, pid): +        """ recheck links in package """ +        data = self.db.getPackageData() + +        urls = [] +         +        for pyfile in data.itervalues(): +            if pyfile.status not in  (0, 12, 13): +                urls.append( ( pyfile["url"], pyfile["plugin"]) ) +                 +        self.core.threadManager.createInfoThread(urls, pid)  #########################################################################  class FileDatabaseBackend(Thread): @@ -689,7 +712,7 @@ class FileDatabaseBackend(Thread):      @async          def updateLinkInfo(self, data):          """ data is list of tupels (name, size, status, url) """ -        self.c.executemany('UPDATE links SET name=?, size=?, status=? WHERE url=?', data) +        self.c.executemany('UPDATE links SET name=?, size=?, status=? WHERE url=? AND status NOT IN (0,12,13)', data)      @queue      def reorderPackage(self, p, position, noMove=False): @@ -765,6 +788,15 @@ class FileDatabaseBackend(Thread):          self.c.execute(cmd) # very bad!          return [x[0] for x in self.c ] +     +    @queue +    #---------------------------------------------------------------------- +    def getUnfinished(self, pid): +        """return list of ids with pyfiles in package not finished or processed""" +         +        self.c.execute("SELECT id FROM links WHERE package=? AND status NOT IN (0, 13)", (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): @@ -954,6 +986,9 @@ class PyPackage():          self.queue = queue          self.order = order          self.priority = priority +         +         +        self.setFinished = False      def toDict(self):          """return data as dict diff --git a/module/PluginThread.py b/module/PluginThread.py index d60880ef3..2a4312ecd 100644 --- a/module/PluginThread.py +++ b/module/PluginThread.py @@ -148,10 +148,9 @@ class DownloadThread(PluginThread):  			self.m.log.info(_("Download finished: %s") % pyfile.name) -			#@TODO hooks, packagaefinished etc -			  			self.m.core.hookManager.downloadFinished(pyfile) +			self.m.core.files.checkPackageFinished(pyfile)  			self.active = False	  			pyfile.finishIfDone() diff --git a/module/plugins/hooks/HotFolder.py b/module/plugins/hooks/HotFolder.py index 3b6c88d82..6c6825954 100644 --- a/module/plugins/hooks/HotFolder.py +++ b/module/plugins/hooks/HotFolder.py @@ -36,7 +36,7 @@ class HotFolder(Hook):                     ("folder", "str", "Folder to observe", "container"),                     ("watch_file", "bool", "Observe link file", "False"),                     ("keep", "bool", "Keep added containers", "True"), -                   ("file", "str", "link file", "links.txt")] +                   ("file", "str", "Link file", "links.txt")]      __threaded__ = []      __author_name__ = ("RaNaN")      __author_mail__ = ("RaNaN@pyload.de") | 
