mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-03-20 03:57:30 +08:00
db lock
This commit is contained in:
@@ -52,6 +52,9 @@ def db_lock(func):
|
||||
|
||||
|
||||
class DbOper:
|
||||
"""
|
||||
数据库操作基类
|
||||
"""
|
||||
_db: Session = None
|
||||
|
||||
def __init__(self, db: Session = None):
|
||||
@@ -59,4 +62,3 @@ class DbOper:
|
||||
self._db = db
|
||||
else:
|
||||
self._db = ScopedSession()
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import time
|
||||
from typing import Tuple, List
|
||||
|
||||
from app.core.context import MediaInfo
|
||||
from app.db import DbOper
|
||||
from app.db import DbOper, db_lock
|
||||
from app.db.models.subscribe import Subscribe
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ class SubscribeOper(DbOper):
|
||||
订阅管理
|
||||
"""
|
||||
|
||||
@db_lock
|
||||
def add(self, mediainfo: MediaInfo, **kwargs) -> Tuple[int, str]:
|
||||
"""
|
||||
新增订阅
|
||||
@@ -57,12 +58,14 @@ class SubscribeOper(DbOper):
|
||||
return Subscribe.get_by_state(self._db, state)
|
||||
return Subscribe.list(self._db)
|
||||
|
||||
@db_lock
|
||||
def delete(self, sid: int):
|
||||
"""
|
||||
删除订阅
|
||||
"""
|
||||
Subscribe.delete(self._db, rid=sid)
|
||||
|
||||
@db_lock
|
||||
def update(self, sid: int, payload: dict) -> Subscribe:
|
||||
"""
|
||||
更新订阅
|
||||
|
||||
Reference in New Issue
Block a user