diff options
author | mkaay <mkaay@mkaay.de> | 2011-12-08 19:45:07 +0100 |
---|---|---|
committer | mkaay <mkaay@mkaay.de> | 2011-12-08 19:45:07 +0100 |
commit | 49a6300d5eea2f1035cb215bf89ce5b945d7339f (patch) | |
tree | 24a3184da18576bc75ca0c7ae6d19c7e76f14fb1 /module | |
parent | partial revert (diff) | |
download | pyload-49a6300d5eea2f1035cb215bf89ce5b945d7339f.tar.xz |
order change updates cache
Diffstat (limited to 'module')
-rw-r--r-- | module/database/FileDatabase.py | 50 |
1 files changed, 37 insertions, 13 deletions
diff --git a/module/database/FileDatabase.py b/module/database/FileDatabase.py index 1df8998b0..47013d8de 100644 --- a/module/database/FileDatabase.py +++ b/module/database/FileDatabase.py @@ -151,6 +151,7 @@ class FileHandler: """delete package and all contained links""" p = self.getPackage(id) + oldorder = o.order if not p: if id in self.packageCache: del self.packageCache[id] @@ -172,6 +173,12 @@ class FileHandler: if id in self.packageCache: del self.packageCache[id] + packs = self.packageCache.values() + for pack in packs: + if pack.queue != queue and p.order < oldorder: + pack.order -= 1 + pack.notifyChange() + #---------------------------------------------------------------------- @lock @change @@ -199,6 +206,12 @@ class FileHandler: p = self.getPackage(pid) if not len(p.getChildren()): p.delete() + + pyfiles = self.cache.values() + for pyfile in pyfiles: + if pyfile.packageid == f["package"] and f["order"] > position: + pyfile.order -= 1 + pyfile.notifyChange() #---------------------------------------------------------------------- def releaseLink(self, id): @@ -416,24 +429,32 @@ class FileHandler: def setPackageLocation(self, id, queue): """push package to queue""" - pack = self.db.getPackage(id) + p = self.db.getPackage(id) + oldorder = p.order - e = RemoveEvent("pack", id, "collector" if not pack.queue else "queue") + e = RemoveEvent("pack", id, "collector" if not p.queue else "queue") self.core.pullManager.addEvent(e) + + self.db.clearPackageOrder(p) - self.db.clearPackageOrder(pack) - - pack = self.db.getPackage(id) + p = self.db.getPackage(id) - pack.queue = queue - self.db.updatePackage(pack) + p.queue = queue + self.db.updatePackage(p) - self.db.reorderPackage(pack, -1, True) + self.db.reorderPackage(p, -1, True) + + packs = self.packageCache.values() + for pack in packs: + if pack.queue != queue and pack.order > oldorder: + pack.order -= 1 + pack.notifyChange() self.db.commit() self.releasePackage(id) - pack = self.getPackage(id) - e = InsertEvent("pack", id, pack.order, "collector" if not pack.queue else "queue") + p = self.getPackage(id) + + e = InsertEvent("pack", id, p.order, "collector" if not p.queue else "queue") self.core.pullManager.addEvent(e) @lock @@ -451,14 +472,16 @@ class FileHandler: if p.order > position: if pack.order >= position and pack.order < p.order: pack.order += 1 + pack.notifyChange() elif p.order < position: if pack.order <= position and pack.order > p.order: pack.order -= 1 + pack.notifyChange() p.order = position self.db.commit() - e = ReloadAllEvent("collector" if not p.queue else "queue") + e = InsertEvent("pack", id, position, "collector" if not p.queue else "queue") self.core.pullManager.addEvent(e) @lock @@ -478,17 +501,18 @@ class FileHandler: if f["order"] > position: if pyfile.order >= position and pyfile.order < f["order"]: pyfile.order += 1 + pyfile.notifyChange() elif f["order"] < position: if pyfile.order <= position and pyfile.order > f["order"]: pyfile.order -= 1 + pyfile.notifyChange() if id in self.cache: self.cache[id].order = position self.db.commit() - e = ReloadAllEvent("collector" if not self.getPackage(f["package"]).queue else "queue") - + e = InsertEvent("file", id, position, "collector" if not self.getPackage(f["package"]).queue else "queue") self.core.pullManager.addEvent(e) @change |