From a916c1f4ad53dd867ec3cc0f4a4a68ff4dfc1572 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Tue, 16 Feb 2021 12:52:32 -0300 Subject: [PATCH] check if db file exists before sync --- lbry/wallet/server/db/elastic_sync.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lbry/wallet/server/db/elastic_sync.py b/lbry/wallet/server/db/elastic_sync.py index 21cf0b353..9a49da2c9 100644 --- a/lbry/wallet/server/db/elastic_sync.py +++ b/lbry/wallet/server/db/elastic_sync.py @@ -1,6 +1,7 @@ import argparse import asyncio import logging +import os from collections import namedtuple from multiprocessing import Process @@ -59,8 +60,8 @@ async def make_es_index(): async def run(args, shard): - def itsbusy(): - logging.info("shard %d: db is busy, retry") + def itsbusy(*_): + logging.info("shard %d: db is busy, retry", shard) return True db = apsw.Connection(args.db_path, flags=apsw.SQLITE_OPEN_READONLY | apsw.SQLITE_OPEN_URI) db.setbusyhandler(itsbusy) @@ -84,6 +85,10 @@ def run_elastic_sync(): args = parser.parse_args() processes = [] + if not os.path.exists(args.db_path): + logging.info("DB path doesnt exist") + return + if not asyncio.run(make_es_index()): logging.info("ES is already initialized") return