From a17ac893c2532edfce44d9d6f4c53f287eb49bd0 Mon Sep 17 00:00:00 2001 From: 3970260761 <3970260761@qq.com> Date: Thu, 12 Nov 2026 19:48:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B3=A8=E5=86=8C=E6=8E=A5=E5=8F=A3=20I?= =?UTF-8?q?NSERT=20=E5=88=97=E6=95=B0=E4=B8=8D=E5=8C=B9=E9=85=8D=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E6=B3=A8=E5=86=8C=E5=A4=B1=E8=B4=A5(502)=EF=BC=9Bconf?= =?UTF-8?q?ig.json=20=E6=8C=82=E8=BD=BD=E4=BF=AE=E5=A4=8D=E5=AE=B9?= =?UTF-8?q?=E5=99=A8=E9=87=8D=E5=BB=BA=E5=90=8E=20DATA=5FDIR=20=E6=BC=82?= =?UTF-8?q?=E7=A7=BB=E5=88=B0=E6=98=93=E5=A4=B1=E5=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - server.py: users 表经 ALTER 迁移为 9 列后注册仍按 4 列全量 VALUES 插入, SQLite 抛 OperationalError → nginx 502「注册失败」;改为显式列名插入, 其余列走 DEFAULT(与 _ensure_admin 写法一致) - docker-compose.yml: 挂载 ./data/config.json 到 DEFAULT_HOST_ROOT 容器路径, _load_storage_root() 才能读到 storage_root=/app/data;此前配置落在容器易失层, 重建容器后 DATA_DIR 漂移到 /vol3/... 易失目录,用户库/密钥/上传全丢(历史用户登录失败) --- docker-compose.yml | 3 +++ server.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 0d552eb..6040c54 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,6 +18,9 @@ services: volumes: # 数据持久化:试用记录 / 用量库 / 用户库 / news.json - ./data:/app/data + # 存储根配置必须持久:_load_storage_root() 读 DEFAULT_HOST_ROOT 容器路径下的 config.json, + # 不挂载则落在容器易失层,重建容器后 storage_root 丢失 → DATA_DIR 漂移到易失目录 → 用户库/密钥全丢 + - ./data/config.json:/vol3/1000/HD3/docker/it-tools-relay/data/config.json cap_add: - NET_ADMIN extra_hosts: diff --git a/server.py b/server.py index ff2ccfe..e416a2c 100644 --- a/server.py +++ b/server.py @@ -1686,7 +1686,7 @@ def user_api(method, sub, payload, handler): conn = _db() try: salt = secrets.token_hex(16) - conn.execute("INSERT INTO users VALUES (?,?,?,?)", (username, salt, _hash_pw(password, salt), time.time())) + conn.execute("INSERT INTO users (username, salt, pw_hash, created) VALUES (?,?,?,?)", (username, salt, _hash_pw(password, salt), time.time())) conn.commit() except sqlite3.IntegrityError: return 409, {"code": 409, "message": "用户名已被注册"}