mirror of https://github.com/morpheus65535/bazarr
Fixed database init issue.
This commit is contained in:
parent
67d67f6527
commit
9cc00ebd65
|
@ -3,6 +3,7 @@ import atexit
|
||||||
import json
|
import json
|
||||||
import ast
|
import ast
|
||||||
import logging
|
import logging
|
||||||
|
import gevent
|
||||||
from peewee import *
|
from peewee import *
|
||||||
from playhouse.sqliteq import SqliteQueueDatabase
|
from playhouse.sqliteq import SqliteQueueDatabase
|
||||||
from playhouse.shortcuts import model_to_dict
|
from playhouse.shortcuts import model_to_dict
|
||||||
|
@ -231,24 +232,34 @@ class TableShowsRootfolder(BaseModel):
|
||||||
primary_key = False
|
primary_key = False
|
||||||
|
|
||||||
|
|
||||||
# Create tables if they don't exists.
|
def init_db():
|
||||||
database.create_tables([System,
|
# Create tables if they don't exists.
|
||||||
TableBlacklist,
|
database.create_tables([System,
|
||||||
TableBlacklistMovie,
|
TableBlacklist,
|
||||||
TableEpisodes,
|
TableBlacklistMovie,
|
||||||
TableHistory,
|
TableEpisodes,
|
||||||
TableHistoryMovie,
|
TableHistory,
|
||||||
TableLanguagesProfiles,
|
TableHistoryMovie,
|
||||||
TableMovies,
|
TableLanguagesProfiles,
|
||||||
TableMoviesRootfolder,
|
TableMovies,
|
||||||
TableSettingsLanguages,
|
TableMoviesRootfolder,
|
||||||
TableSettingsNotifier,
|
TableSettingsLanguages,
|
||||||
TableShows,
|
TableSettingsNotifier,
|
||||||
TableShowsRootfolder])
|
TableShows,
|
||||||
|
TableShowsRootfolder])
|
||||||
|
|
||||||
|
# add the system table single row if it's not existing
|
||||||
|
# we must retry until the tables are created
|
||||||
|
tables_created = False
|
||||||
|
while not tables_created:
|
||||||
|
try:
|
||||||
|
if not System.select().count():
|
||||||
|
System.insert({System.configured: '0', System.updated: '0'}).execute()
|
||||||
|
except:
|
||||||
|
gevent.sleep(0.1)
|
||||||
|
else:
|
||||||
|
tables_created = True
|
||||||
|
|
||||||
# add the system table single row if it's not existing
|
|
||||||
if not System.select().count():
|
|
||||||
System.insert({System.configured: '0', System.updated: '0'}).execute()
|
|
||||||
|
|
||||||
class SqliteDictPathMapper:
|
class SqliteDictPathMapper:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
|
@ -10,6 +10,7 @@ from config import settings, configure_captcha_func
|
||||||
from get_args import args
|
from get_args import args
|
||||||
from logger import configure_logging
|
from logger import configure_logging
|
||||||
from helper import path_mappings
|
from helper import path_mappings
|
||||||
|
from database import init_db
|
||||||
|
|
||||||
from dogpile.cache.region import register_backend as register_cache_backend
|
from dogpile.cache.region import register_backend as register_cache_backend
|
||||||
import subliminal
|
import subliminal
|
||||||
|
@ -174,5 +175,6 @@ def init_binaries():
|
||||||
return unrar
|
return unrar
|
||||||
|
|
||||||
|
|
||||||
|
init_db()
|
||||||
init_binaries()
|
init_binaries()
|
||||||
path_mappings.update()
|
path_mappings.update()
|
||||||
|
|
Loading…
Reference in New Issue