put session files under data folder

This commit is contained in:
əlemi 2022-05-23 02:36:44 +02:00
parent 847bde3d79
commit 76c84006ad
No known key found for this signature in database
GPG key ID: BBCBFE5D7244634E
3 changed files with 9 additions and 5 deletions

View file

@ -87,6 +87,11 @@ def main():
if args.server:
kwargs["server"] = args.server
if not os.path.isdir('log'):
os.mkdir('log')
if not os.path.isdir('data'):
os.mkdir('data')
try:
client = Treepuncher(
args.name,

View file

@ -27,8 +27,8 @@ class Storage:
def __init__(self, name:str):
self.name = name
init = not os.path.isfile(f"{name}.session")
self.db = sqlite3.connect(f'{name}.session')
init = not os.path.isfile(name)
self.db = sqlite3.connect(name)
if init:
self._init_db()

View file

@ -50,8 +50,7 @@ class Treepuncher(
self.name = name
self.config = ConfigParser()
config_path = config_file or f'{self.name}.ini'
self.config.read(config_path)
self.config.read(config_file or f"{self.name}.ini") # TODO wrap with pathlib
authenticator : AuthInterface
@ -94,7 +93,7 @@ class Treepuncher(
resolve_srv=opt('resolve_srv', default=True, t=bool),
)
self.storage = Storage(self.name)
self.storage = Storage(opt('session_file') or f"data/{name}.session") # TODO wrap with pathlib
self.notifier = Notifier(self)