fixed bug where tables/default settings were firing each restart

This commit is contained in:
Phillip Tarrant 2020-09-22 15:00:05 -04:00
parent c896a12b17
commit 2eeee9d6c4
2 changed files with 11 additions and 5 deletions

View File

@ -43,6 +43,7 @@ class Users(BaseModel):
class Meta:
table_name = "users"
class Audit_Log(BaseModel):
audit_id = AutoField()
created = DateTimeField(default=datetime.datetime.now)
@ -53,7 +54,6 @@ class Audit_Log(BaseModel):
log_msg = TextField(default='')
class Host_Stats(BaseModel):
time = DateTimeField(default=datetime.datetime.now)
boot_time = CharField(default="")
@ -167,7 +167,8 @@ class db_builder:
@staticmethod
def default_settings():
logger.info("Fresh Install Detected - Creating Default Settings")
console.info("Fresh Install Detected - Creating Default Settings")
default_data = helper.find_default_password()
username = default_data.get("username", 'admin')
@ -185,9 +186,12 @@ class db_builder:
@staticmethod
def is_fresh_install():
if helper.check_file_exists(helper.db_path):
try:
user = Users.get_by_id(1)
return False
except:
return True
pass
class db_shortcuts:

View File

@ -82,7 +82,9 @@ if __name__ == '__main__':
helper.create_session_file(ignore=args.ignore)
# do our installer stuff
if not installer.is_fresh_install():
fresh_install = installer.is_fresh_install()
if fresh_install:
installer.create_tables()
installer.default_settings()