Puts safeguards in place to avoid database deletion
This commit is contained in:
parent
fec97ca7b7
commit
3a5b403ff1
1 changed files with 7 additions and 4 deletions
11
src/app.py
11
src/app.py
|
@ -1,10 +1,11 @@
|
||||||
# cython: language_level=3
|
# cython: language_level=3
|
||||||
import logging
|
import logging
|
||||||
|
import pathlib
|
||||||
|
import re
|
||||||
|
|
||||||
import aiojobs.aiohttp
|
import aiojobs.aiohttp
|
||||||
import asyncio
|
import asyncio
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
import re
|
|
||||||
|
|
||||||
import schema.db_helpers
|
import schema.db_helpers
|
||||||
from src.database import obtain_connection
|
from src.database import obtain_connection
|
||||||
|
@ -13,7 +14,6 @@ from src.handles import create_comment_scheduler
|
||||||
from src.settings import config_path, get_config
|
from src.settings import config_path, get_config
|
||||||
from src.writes import DatabaseWriter
|
from src.writes import DatabaseWriter
|
||||||
|
|
||||||
|
|
||||||
config = get_config(config_path)
|
config = get_config(config_path)
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
@ -38,8 +38,11 @@ logger.addHandler(stdout_handler)
|
||||||
|
|
||||||
|
|
||||||
async def setup_db_schema(app):
|
async def setup_db_schema(app):
|
||||||
logger.info('Setting up schema in %s', app['db_path'])
|
if not pathlib.Path(app['db_path']).exists():
|
||||||
schema.db_helpers.setup_database(app['db_path'])
|
logger.info('Setting up schema in %s', app['db_path'])
|
||||||
|
schema.db_helpers.setup_database(app['db_path'])
|
||||||
|
else:
|
||||||
|
logger.info('Database already exists in %s, skipping setup', app['db_path'])
|
||||||
|
|
||||||
|
|
||||||
async def close_comment_scheduler(app):
|
async def close_comment_scheduler(app):
|
||||||
|
|
Loading…
Reference in a new issue