This commit is contained in:
iamBadgers committed 2026-04-26 16:38:53 -07:00
1 parent b95fd394df
commit 41158cdd1c
4 files changed
+29 -5

No files matched your search

+14 -3
View File
@@ -2,6 +2,7 @@ import docker
import os
import socket
import inspect
import shutil
from flask import current_app
from game_table_model import GameTable
from key_model import TableKey
@@ -31,13 +32,23 @@ def build_container_routing_labels(prefix: str, strip_prefix=True):
return labels
def delete_container(docker_id) -> bool:
if not docker_id:
def delete_file_package(table: GameTable) -> bool:
if table.active:
return False
if not os.path.exists("/data/{prefix}".format(prefix=table.game_table_link)):
return False
shutil.rmtree("/data/{prefix}".format(prefix=table.game_table_link))
os.removedir("/data/{prefix}")
return True
def delete_container(table: GameTable) -> bool:
if not table.docker_id:
return False
try:
client = docker.from_env()
container = client.containers.get(docker_id)
container = client.containers.get(table.docker_id)
container.remove()
return True
except (docker.errors.NotFound, docker.errors.APIError):
+1
View File
@@ -1,5 +1,6 @@
from main import db
class TableKey(db.Model):
__tablename__ = "game_keys"
+2 -2
View File
@@ -49,6 +49,7 @@ def update_table(table_id):
@tables.route("tables/<table_id>", methods=["DELETE"])
def delete_table(table_id):
table = GameTable.query.get_or_404(table_id)
container_managment.delete_file_package(table)
potato.session.delete(table)
potato.session.commit()
return jsonify({}), 200
@@ -90,7 +91,7 @@ def activate_table(table_id):
key.reserve(table.game_table_id)
table.active = True
if hard:
container_managment.delete_container(table.docker_id)
container_managment.delete_container(table)
table.docker_id = container_managment.start_foundry_container(table, key)
potato.session.commit()
return jsonify(table.to_dict())
@@ -112,4 +113,3 @@ def deactivate_table(table_id):
potato.session.commit()
return jsonify(table.to_dict())
+12
View File
@@ -0,0 +1,12 @@
from main import db
class User(db.Model):
__tablename__ = "users"
user_id = db.Column(db.Integer, primary_key=True)
password_hash = db.Column(db.Text)
user_name = db.Column(db.Text, unique=True)