summaryrefslogtreecommitdiffstats
path: root/module/database/DatabaseBackend.py
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-06-02 17:01:59 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-06-02 17:01:59 +0200
commit56754bcdbd15db520318a88ac779e1eb027853a8 (patch)
tree2d1a09b3fbe36eb6575e2ea757014b5c3d2dcb46 /module/database/DatabaseBackend.py
parentupload to fix (diff)
downloadpyload-56754bcdbd15db520318a88ac779e1eb027853a8.tar.xz
added several checks to improve stability
Diffstat (limited to 'module/database/DatabaseBackend.py')
-rw-r--r--module/database/DatabaseBackend.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/module/database/DatabaseBackend.py b/module/database/DatabaseBackend.py
index 95bb6a198..c147aa018 100644
--- a/module/database/DatabaseBackend.py
+++ b/module/database/DatabaseBackend.py
@@ -233,8 +233,27 @@ class DatabaseBackend(Thread):
self.c.executemany("INSERT INTO users(name, password, email) VALUES (?, ?, ?)", users)
move("pyload.db", "pyload.old.db")
-
+
+ #try to lower ids
+ self.c.execute('SELECT max(id) FROM LINKS')
+ fid = self.c.fetchone()[0]
+ if fid:
+ fid = int(fid)
+ else:
+ fid = 0
+ self.c.execute('UPDATE SQLITE_SEQUENCE SET seq=? WHERE name=?', (fid, "links"))
+
+
+ self.c.execute('SELECT max(id) FROM packages')
+ pid = self.c.fetchone()[0]
+ if pid:
+ pid = int(fid)
+ else:
+ pid = 0
+ self.c.execute('UPDATE SQLITE_SEQUENCE SET seq=? WHERE name=?', (pid, "packages"))
+
self.c.execute('VACUUM')
+
def createCursor(self):
return self.conn.cursor()