summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormorpheus65535 <[email protected]>2021-05-27 12:28:46 -0400
committermorpheus65535 <[email protected]>2021-05-27 12:28:46 -0400
commit9cc00ebd65597f3690bc16a0d4f9fa73e8bb6d08 (patch)
tree11dca99b109ed4a627c24763e4e69033362fa372
parent67d67f6527b0ecb6f3176bac85d2e8b849b94b73 (diff)
downloadbazarr-9cc00ebd65597f3690bc16a0d4f9fa73e8bb6d08.tar.gz
bazarr-9cc00ebd65597f3690bc16a0d4f9fa73e8bb6d08.zip
Fixed database init issue.v0.9.6-beta.12
-rw-r--r--bazarr/database.py47
-rw-r--r--bazarr/init.py2
2 files changed, 31 insertions, 18 deletions
diff --git a/bazarr/database.py b/bazarr/database.py
index 44fa35ac1..0619773d2 100644
--- a/bazarr/database.py
+++ b/bazarr/database.py
@@ -3,6 +3,7 @@ import atexit
import json
import ast
import logging
+import gevent
from peewee import *
from playhouse.sqliteq import SqliteQueueDatabase
from playhouse.shortcuts import model_to_dict
@@ -231,24 +232,34 @@ class TableShowsRootfolder(BaseModel):
primary_key = False
-# Create tables if they don't exists.
-database.create_tables([System,
- TableBlacklist,
- TableBlacklistMovie,
- TableEpisodes,
- TableHistory,
- TableHistoryMovie,
- TableLanguagesProfiles,
- TableMovies,
- TableMoviesRootfolder,
- TableSettingsLanguages,
- TableSettingsNotifier,
- TableShows,
- TableShowsRootfolder])
-
-# 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()
+def init_db():
+ # Create tables if they don't exists.
+ database.create_tables([System,
+ TableBlacklist,
+ TableBlacklistMovie,
+ TableEpisodes,
+ TableHistory,
+ TableHistoryMovie,
+ TableLanguagesProfiles,
+ TableMovies,
+ TableMoviesRootfolder,
+ TableSettingsLanguages,
+ TableSettingsNotifier,
+ 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
+
class SqliteDictPathMapper:
def __init__(self):
diff --git a/bazarr/init.py b/bazarr/init.py
index 176f03bf5..dcaf0c776 100644
--- a/bazarr/init.py
+++ b/bazarr/init.py
@@ -10,6 +10,7 @@ from config import settings, configure_captcha_func
from get_args import args
from logger import configure_logging
from helper import path_mappings
+from database import init_db
from dogpile.cache.region import register_backend as register_cache_backend
import subliminal
@@ -174,5 +175,6 @@ def init_binaries():
return unrar
+init_db()
init_binaries()
path_mappings.update()