mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Revert "Merge branch 'bug/DB_Lock' into 'dev'"
This reverts merge request !241
This commit is contained in:
@ -6,6 +6,7 @@ from app.classes.shared.main_models import db_helper
|
||||
|
||||
try:
|
||||
from peewee import (
|
||||
SqliteDatabase,
|
||||
Model,
|
||||
ForeignKeyField,
|
||||
CharField,
|
||||
@ -15,7 +16,6 @@ try:
|
||||
IntegerField,
|
||||
FloatField,
|
||||
)
|
||||
from playhouse.sqliteq import SqliteQueueDatabase
|
||||
|
||||
except ModuleNotFoundError as e:
|
||||
helper.auto_installer_fix(e)
|
||||
@ -23,9 +23,8 @@ except ModuleNotFoundError as e:
|
||||
logger = logging.getLogger(__name__)
|
||||
peewee_logger = logging.getLogger("peewee")
|
||||
peewee_logger.setLevel(logging.INFO)
|
||||
database = SqliteQueueDatabase(
|
||||
helper.db_path
|
||||
# pragmas={"journal_mode": "wal", "cache_size": -1024 * 10}
|
||||
database = SqliteDatabase(
|
||||
helper.db_path, pragmas={"journal_mode": "wal", "cache_size": -1024 * 10}
|
||||
)
|
||||
|
||||
# **********************************************************************************
|
||||
@ -142,7 +141,8 @@ class helper_servers:
|
||||
|
||||
@staticmethod
|
||||
def remove_server(server_id):
|
||||
Servers.delete().where(Servers.server_id == server_id).execute()
|
||||
with database.atomic():
|
||||
Servers.delete().where(Servers.server_id == server_id).execute()
|
||||
|
||||
@staticmethod
|
||||
def get_server_data_by_id(server_id):
|
||||
@ -224,21 +224,24 @@ class helper_servers:
|
||||
|
||||
@staticmethod
|
||||
def sever_crashed(server_id):
|
||||
Server_Stats.update(crashed=True).where(
|
||||
Server_Stats.server_id == server_id
|
||||
).execute()
|
||||
with database.atomic():
|
||||
Server_Stats.update(crashed=True).where(
|
||||
Server_Stats.server_id == server_id
|
||||
).execute()
|
||||
|
||||
@staticmethod
|
||||
def set_download(server_id):
|
||||
Server_Stats.update(downloading=True).where(
|
||||
Server_Stats.server_id == server_id
|
||||
).execute()
|
||||
with database.atomic():
|
||||
Server_Stats.update(downloading=True).where(
|
||||
Server_Stats.server_id == server_id
|
||||
).execute()
|
||||
|
||||
@staticmethod
|
||||
def finish_download(server_id):
|
||||
Server_Stats.update(downloading=False).where(
|
||||
Server_Stats.server_id == server_id
|
||||
).execute()
|
||||
with database.atomic():
|
||||
Server_Stats.update(downloading=False).where(
|
||||
Server_Stats.server_id == server_id
|
||||
).execute()
|
||||
|
||||
@staticmethod
|
||||
def get_download_status(server_id):
|
||||
@ -249,9 +252,10 @@ class helper_servers:
|
||||
|
||||
@staticmethod
|
||||
def server_crash_reset(server_id):
|
||||
Server_Stats.update(crashed=False).where(
|
||||
Server_Stats.server_id == server_id
|
||||
).execute()
|
||||
with database.atomic():
|
||||
Server_Stats.update(crashed=False).where(
|
||||
Server_Stats.server_id == server_id
|
||||
).execute()
|
||||
|
||||
@staticmethod
|
||||
def is_crashed(server_id):
|
||||
@ -268,9 +272,10 @@ class helper_servers:
|
||||
Server_Stats.select().where(Server_Stats.server_id == server_id)
|
||||
except Exception as ex:
|
||||
logger.error(f"Database entry not found! {ex}")
|
||||
Server_Stats.update(updating=value).where(
|
||||
Server_Stats.server_id == server_id
|
||||
).execute()
|
||||
with database.atomic():
|
||||
Server_Stats.update(updating=value).where(
|
||||
Server_Stats.server_id == server_id
|
||||
).execute()
|
||||
|
||||
@staticmethod
|
||||
def get_update_status(server_id):
|
||||
@ -288,9 +293,10 @@ class helper_servers:
|
||||
except Exception as ex:
|
||||
logger.error(f"Database entry not found! {ex}")
|
||||
return
|
||||
Server_Stats.update(first_run=False).where(
|
||||
Server_Stats.server_id == server_id
|
||||
).execute()
|
||||
with database.atomic():
|
||||
Server_Stats.update(first_run=False).where(
|
||||
Server_Stats.server_id == server_id
|
||||
).execute()
|
||||
|
||||
@staticmethod
|
||||
def get_first_run(server_id):
|
||||
@ -331,9 +337,10 @@ class helper_servers:
|
||||
Server_Stats.select().where(Server_Stats.server_id == server_id)
|
||||
except Exception as ex:
|
||||
logger.error(f"Database entry not found! {ex}")
|
||||
Server_Stats.update(waiting_start=value).where(
|
||||
Server_Stats.server_id == server_id
|
||||
).execute()
|
||||
with database.atomic():
|
||||
Server_Stats.update(waiting_start=value).where(
|
||||
Server_Stats.server_id == server_id
|
||||
).execute()
|
||||
|
||||
@staticmethod
|
||||
def get_waiting_start(server_id):
|
||||
|
Reference in New Issue
Block a user