Skip to content

Commit

Permalink
Fix the version check when no database exists
Browse files Browse the repository at this point in the history
  • Loading branch information
midgetspy committed Mar 12, 2013
1 parent baa2068 commit c476734
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 5 additions & 2 deletions SickBeard.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,11 @@ def main():
sickbeard.CFG = ConfigObj(sickbeard.CONFIG_FILE)

if db.DBConnection().checkDBVersion() > MAX_DB_VERSION:
print 'Your database version has been incremented past what this version of Sick Beard supports.'
print 'Have you used other forks of Sick Beard with this same database file?'
print 'Your database version has been incremented'
print 'past what this version of Sick Beard supports.'
print
print 'If you have used other forks of SB which have'
print 'modified your database it may now be unusable.'
sys.exit(1)

# Initialize the config and our threads
Expand Down
7 changes: 6 additions & 1 deletion sickbeard/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ def __init__(self, filename="sickbeard.db", suffix=None, row_type=None):
self.connection.row_factory = sqlite3.Row

def checkDBVersion(self):
result = self.select("SELECT db_version FROM db_version")
try:
result = self.select("SELECT db_version FROM db_version")
except sqlite3.OperationalError, e:
if "no such table: db_version" in e.message:
return 0

if result:
return int(result[0]["db_version"])
else:
Expand Down

0 comments on commit c476734

Please sign in to comment.