diff options
author | Vuolter <vuolter@gmail.com> | 2013-05-15 13:41:01 +0200 |
---|---|---|
committer | Vuolter <vuolter@gmail.com> | 2013-05-17 18:26:05 +0200 |
commit | e2557715e85974c5ec3a1aac4c1dccf21de24a2a (patch) | |
tree | 2d739c6e32f9a3214330c0b257fa594de5b2e785 /module/plugins/hooks/DeleteFinished.py | |
parent | Merge branch 'stable' of https://github.com/pyload/pyload into stable (diff) | |
download | pyload-e2557715e85974c5ec3a1aac4c1dccf21de24a2a.tar.xz |
Version 1.00: delete finished packages only instead all finished links
Diffstat (limited to 'module/plugins/hooks/DeleteFinished.py')
-rw-r--r-- | module/plugins/hooks/DeleteFinished.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/module/plugins/hooks/DeleteFinished.py b/module/plugins/hooks/DeleteFinished.py index e0df69eef..29959eb57 100644 --- a/module/plugins/hooks/DeleteFinished.py +++ b/module/plugins/hooks/DeleteFinished.py @@ -18,12 +18,13 @@ """ from module.plugins.Hook import Hook +from module.database import style from time import time class DeleteFinished(Hook): __name__ = "DeleteFinished" - __version__ = "0.5" + __version__ = "1.00" __description__ = "Automatically delete finished packages from queue" __config__ = [ ("activated", "bool", "Activated", "False"), @@ -32,6 +33,11 @@ class DeleteFinished(Hook): __author_name__ = ("Walter Purcaro") __author_mail__ = ("vuolter@gmail.com") + @style.queue + def deleteFinished(self): + self.c.execute("DELETE FROM packages WHERE NOT EXISTS(SELECT 1 FROM links WHERE package=packages.id AND status NOT IN (0,4))") + self.c.execute("DELETE FROM links WHERE NOT EXISTS(SELECT 1 FROM packages WHERE id=links.package)") + def wakeup(self, pypack): # self.logDebug("self.wakeup") self.removeEvent("packageFinished", self.wakeup) @@ -40,8 +46,8 @@ class DeleteFinished(Hook): def periodical(self): # self.logDebug("self.periodical") if not self.info["sleep"]: - self.core.api.deleteFinished() - self.logDebug("called self.core.api.deleteFinished") + self.logInfo("self.deleteFinished") + self.deleteFinished() self.info["sleep"] = True self.addEvent("packageFinished", self.wakeup) @@ -72,6 +78,7 @@ class DeleteFinished(Hook): interval = self.getConfig("interval") * 3600 if interval != self.interval: self.interval = interval + self.initPeriodical() def unload(self): # self.logDebug("self.unload") |