修复高优先级安全和稳定性问题
1. app.py:
- 添加user_semaphores_lock线程锁,修复get_user_semaphore竞态条件
- 将9处裸except:改为except Exception:或具体异常类型
2. database.py:
- 将3处裸except:改为except Exception:
3. email_service.py:
- 添加_smtp_config_lock线程锁
- 修复daily_sent计数竞态条件:获取配置时预增,失败时回退
- _get_available_smtp_config和_get_next_available_smtp_config使用锁保护
🤖 Generated with Claude Code
This commit is contained in:
@@ -837,7 +837,7 @@ def update_user_email(user_id, email, verified=False):
|
||||
# 先检查email_verified字段是否存在,不存在则添加
|
||||
try:
|
||||
cursor.execute('SELECT email_verified FROM users LIMIT 1')
|
||||
except:
|
||||
except Exception:
|
||||
cursor.execute('ALTER TABLE users ADD COLUMN email_verified INTEGER DEFAULT 0')
|
||||
conn.commit()
|
||||
|
||||
@@ -857,7 +857,7 @@ def update_user_email_notify(user_id, enabled):
|
||||
# 先检查字段是否存在
|
||||
try:
|
||||
cursor.execute('SELECT email_notify_enabled FROM users LIMIT 1')
|
||||
except:
|
||||
except Exception:
|
||||
cursor.execute('ALTER TABLE users ADD COLUMN email_notify_enabled INTEGER DEFAULT 1')
|
||||
conn.commit()
|
||||
|
||||
@@ -881,7 +881,7 @@ def get_user_email_notify(user_id):
|
||||
if row is None:
|
||||
return True
|
||||
return bool(row[0]) if row[0] is not None else True
|
||||
except:
|
||||
except Exception:
|
||||
return True # 字段不存在时默认开启
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user