added db_url to config

This commit is contained in:
Lex Berezhny 2020-05-18 08:13:29 -04:00
parent 955e44631d
commit 5d6388b366

View file

@ -504,6 +504,8 @@ class CLIConfig(TranscodeConfig):
class Config(CLIConfig): class Config(CLIConfig):
db_url = String("Database connection URL, uses a local file based SQLite by default.")
# directories # directories
data_dir = Path("Directory path to store blobs.", metavar='DIR') data_dir = Path("Directory path to store blobs.", metavar='DIR')
download_dir = Path( download_dir = Path(
@ -619,10 +621,7 @@ class Config(CLIConfig):
True True
) )
lbrycrd_dir = Path( lbrycrd_dir = Path("Directory containing lbrycrd data.", metavar='DIR')
"Directory containing lbrycrd data.",
previous_names=['lbrycrd_dir'], metavar='DIR'
)
# daemon # daemon
save_files = Toggle("Save downloaded files when calling `get` by default", True) save_files = Toggle("Save downloaded files when calling `get` by default", True)
@ -688,6 +687,14 @@ class Config(CLIConfig):
def log_file_path(self): def log_file_path(self):
return os.path.join(self.data_dir, 'lbrynet.log') return os.path.join(self.data_dir, 'lbrynet.log')
@property
def db_url_or_default(self):
if self.db_url:
return self.db_url
return 'sqlite://'+os.path.join(
self.data_dir, self.blockchain_name, 'blockchain.db'
)
def get_windows_directories() -> typing.Tuple[str, str, str]: def get_windows_directories() -> typing.Tuple[str, str, str]:
from lbry.winpaths import get_path, FOLDERID, UserHandle, \ from lbry.winpaths import get_path, FOLDERID, UserHandle, \