summaryrefslogtreecommitdiffstats
path: root/module/FileDatabase.py
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-01-08 00:15:04 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-01-08 00:15:04 +0100
commit4bbb75de3ee0b0f02408f8c39d82004b7209ea7e (patch)
treee61aede937e5f0011a8432a99ec90098e9bf0251 /module/FileDatabase.py
parentnew l18n files (diff)
downloadpyload-4bbb75de3ee0b0f02408f8c39d82004b7209ea7e.tar.xz
new buttons to (remove finished/restart failed) links
Diffstat (limited to 'module/FileDatabase.py')
-rw-r--r--module/FileDatabase.py43
1 files changed, 41 insertions, 2 deletions
diff --git a/module/FileDatabase.py b/module/FileDatabase.py
index 818c6ed07..631269030 100644
--- a/module/FileDatabase.py
+++ b/module/FileDatabase.py
@@ -165,6 +165,7 @@ class FileHandler:
p = self.getPackage(id)
if not p:
+ if self.packageCache.has_key(id): del self.packageCache[id]
return
e = RemoveEvent("pack", id, "collector" if not p.queue else "queue")
@@ -208,7 +209,7 @@ class FileHandler:
self.core.pullManager.addEvent(e)
p = self.getPackage(pid)
- if len(p.getChildren()) == 0:
+ if not len(p.getChildren()):
p.delete()
#----------------------------------------------------------------------
@@ -507,6 +508,34 @@ class FileHandler:
self.core.threadManager.createInfoThread(urls, pid)
+ @lock
+ @change
+ def deleteFinishedLinks(self):
+ """ deletes finished links and packages, return deleted packages """
+
+ old_packs = self.getInfoData(0)
+ old_packs.update(self.getInfoData(1))
+
+ self.db.deleteFinished()
+
+ new_packs = self.db.getAllPackages(0)
+ new_packs.update(self.db.getAllPackages(1))
+ #get new packages only from db
+
+ deleted = []
+ for id in old_packs.iterkeys():
+ if not new_packs.has_key(str(id)):
+ deleted.append(id)
+ self.deletePackage(int(id))
+
+ return deleted
+
+ @lock
+ @change
+ def restartFailed(self):
+ """ restart all failed links """
+ self.db.restartFailed()
+
#########################################################################
class FileDatabaseBackend(Thread):
"""underlying backend for the filehandler to save the data"""
@@ -879,7 +908,7 @@ class FileDatabaseBackend(Thread):
cmd = "("
for i, item in enumerate(occ):
- if i != 0: cmd += ", "
+ if i: cmd += ", "
cmd += "'%s'" % item
cmd += ")"
@@ -906,6 +935,16 @@ class FileDatabaseBackend(Thread):
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]
+ @queue
+ def deleteFinished(self):
+ self.c.execute("DELETE FROM links WHERE status=0")
+ self.c.execute("DELETE FROM packages WHERE NOT EXISTS(SELECT 1 FROM links WHERE packages.id=links.package)")
+
+
+ @queue
+ def restartFailed(self):
+ self.c.execute("UPDATE links SET status=3,error='' WHERE status IN (8, 9)")
+
if __name__ == "__main__":
pypath = "."