summaryrefslogtreecommitdiffstats
path: root/pyload/database
diff options
context:
space:
mode:
authorGravatar ardi69 <armin@diedering.de> 2015-04-21 20:52:58 +0200
committerGravatar ardi69 <armin@diedering.de> 2015-04-21 20:52:58 +0200
commit0bac5c219498c443495533066f6fd10a972dc1a7 (patch)
treea3c24328d8b7262199125151405b31e72b0ff5e0 /pyload/database
parentrevert for merge (diff)
parentSpare code cosmetics (10) (diff)
downloadpyload-0bac5c219498c443495533066f6fd10a972dc1a7.tar.xz
Merge pull request #5 from vuolter/0.4.10
Spare code cosmetics (10)
Diffstat (limited to 'pyload/database')
-rw-r--r--pyload/database/Backend.py26
1 files changed, 15 insertions, 11 deletions
diff --git a/pyload/database/Backend.py b/pyload/database/Backend.py
index b6540b2be..e851885c0 100644
--- a/pyload/database/Backend.py
+++ b/pyload/database/Backend.py
@@ -175,18 +175,22 @@ class DatabaseBackend(Thread):
f.write(str(DB_VERSION))
return
- with open("files.version", "wb+") as f:
- v = int(f.read().strip())
- if v < DB_VERSION:
- if v < 2:
- try:
- self.manager.core.log.warning(_("Filedatabase was deleted due to incompatible version."))
- except Exception:
- print "Filedatabase was deleted due to incompatible version."
- remove("files.version")
- move("files.db", "files.backup.db")
+ with open("files.version", "rb") as f:
+ v = int(f.read().strip() or 0)
+
+ if v < DB_VERSION:
+ if v < 2:
+ try:
+ self.manager.core.log.warning(_("Filedatabase was deleted due to incompatible version."))
+ except Exception:
+ print "Filedatabase was deleted due to incompatible version."
+ remove("files.version")
+ move("files.db", "files.backup.db")
+
+ with open("files.version", "wb") as f:
f.write(str(DB_VERSION))
- return v
+
+ return v
def _convertDB(self, v):