summaryrefslogtreecommitdiffstats
path: root/module/database/FileDatabase.py
diff options
context:
space:
mode:
authorGravatar mkaay <mkaay@mkaay.de> 2011-12-12 22:28:34 +0100
committerGravatar mkaay <mkaay@mkaay.de> 2011-12-12 22:28:34 +0100
commit63ee2af60d047f3e3ae7ae9536f5a4909e81176c (patch)
treedb77d0a3e95d1aaf6d3cb19a683519a279f2c9ba /module/database/FileDatabase.py
parentimprove mediafire plugin (diff)
downloadpyload-63ee2af60d047f3e3ae7ae9536f5a4909e81176c.tar.xz
deletion fix
Diffstat (limited to 'module/database/FileDatabase.py')
-rw-r--r--module/database/FileDatabase.py42
1 files changed, 41 insertions, 1 deletions
diff --git a/module/database/FileDatabase.py b/module/database/FileDatabase.py
index d51241591..d0eff0d98 100644
--- a/module/database/FileDatabase.py
+++ b/module/database/FileDatabase.py
@@ -152,6 +152,7 @@ class FileHandler:
p = self.getPackage(id)
oldorder = p.order
+ queue = p.queue
if not p:
if id in self.packageCache: del self.packageCache[id]
@@ -175,7 +176,11 @@ class FileHandler:
packs = self.packageCache.values()
for pack in packs:
+<<<<<<< mine
+ if pack.queue == queue and pack.order > oldorder:
+=======
if pack.queue == p.queue and p.order < oldorder:
+>>>>>>> theirs
pack.order -= 1
pack.notifyChange()
@@ -193,6 +198,7 @@ class FileHandler:
e = RemoveEvent("file", id, "collector" if not f.package().queue else "queue")
oldorder = f.order
+ package = f.package
if id in self.core.threadManager.processingIds():
self.cache[id].abortDownload()
@@ -210,7 +216,7 @@ class FileHandler:
pyfiles = self.cache.values()
for pyfile in pyfiles:
- if pyfile.packageid == f["package"] and pyfile.order > oldorder:
+ if pyfile.packageid == package and pyfile.order > oldorder:
pyfile.order -= 1
pyfile.notifyChange()
@@ -574,6 +580,11 @@ class FileHandler:
""" restart all failed links """
self.db.restartFailed()
+ @lock
+ @change
+ def fixPackageOrder(self, queue=0):
+ self.db.fixPackageOrder(queue)
+
class FileMethods():
@style.queue
def filecount(self, queue):
@@ -883,6 +894,35 @@ class FileMethods():
@style.queue
+ def fixPackageOrder(self, queue=0):
+ found = 0
+ order = 0
+ i = 0
+ self.c.execute("SELECT count(*) FROM packages WHERE queue = ?", (queue, ))
+ count = self.c.fetchone()[0]
+ if count == 0:
+ return
+ while order < count:
+ self.c.execute("SELECT id FROM packages WHERE packageorder = ? AND queue = ?", (i, queue))
+ all = self.c.fetchall()
+ if len(all) == 0:
+ i += 1
+ elif len(all) == 1:
+ self.c.execute("UPDATE packages SET packageorder=? WHERE id = ?", (order, all[0][0]))
+ order += 1
+ i += 1
+ elif len(all) > 1:
+ self.c.execute("UPDATE packages SET packageorder=? WHERE id = ?", (order, all[0][0]))
+ order += 1
+ i += len(all)
+ del all[0]
+ self.c.execute("UPDATE packages SET packageorder=packageorder+? WHERE packageorder >= ? AND queue=?", (len(all), order, queue))
+ for r in all:
+ self.c.execute("UPDATE packages SET packageorder=? WHERE id = ?", order, r[0])
+ order += 1
+
+
+ @style.queue
def findDuplicates(self, id, folder, filename):
""" checks if filename exists with different id and same package """
self.c.execute("SELECT l.plugin FROM links as l INNER JOIN packages as p ON l.package=p.id AND p.folder=? WHERE l.id!=? AND l.status=0 AND l.name=?", (folder, id, filename))