From 99218515eaeb26e4571dd92dff199ea234fffd83 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Tue, 5 Sep 2023 16:12:43 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E9=83=A8=E5=88=86=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E6=93=8D=E4=BD=9C=E6=B2=A1=E6=9C=89Commit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/db/__init__.py | 6 +++--- app/db/models/downloadhistory.py | 5 +++-- app/db/models/plugin.py | 3 ++- app/db/models/transferhistory.py | 1 + 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/db/__init__.py b/app/db/__init__.py index acae147d..e18a61e8 100644 --- a/app/db/__init__.py +++ b/app/db/__init__.py @@ -8,8 +8,9 @@ Engine = create_engine(f"sqlite:///{settings.CONFIG_PATH}/user.db", pool_pre_ping=True, echo=False, poolclass=QueuePool, - pool_size=1000, - pool_recycle=60 * 10, + pool_size=1024, + pool_recycle=600, + pool_timeout=180, max_overflow=0) # 会话工厂 SessionFactory = sessionmaker(autocommit=False, autoflush=False, bind=Engine) @@ -33,7 +34,6 @@ def get_db(): class DbOper: - _db: Session = None def __init__(self, db: Session = None): diff --git a/app/db/models/downloadhistory.py b/app/db/models/downloadhistory.py index 6f911902..0999c86b 100644 --- a/app/db/models/downloadhistory.py +++ b/app/db/models/downloadhistory.py @@ -130,9 +130,10 @@ class DownloadFiles(Base): @staticmethod def delete_by_fullpath(db: Session, fullpath: str): - return db.query(DownloadFiles).filter(DownloadFiles.fullpath == fullpath, - DownloadFiles.state == 1).update( + db.query(DownloadFiles).filter(DownloadFiles.fullpath == fullpath, + DownloadFiles.state == 1).update( { "state": 0 } ) + db.commit() diff --git a/app/db/models/plugin.py b/app/db/models/plugin.py index b1717043..e4af5e58 100644 --- a/app/db/models/plugin.py +++ b/app/db/models/plugin.py @@ -23,7 +23,8 @@ class PluginData(Base): @staticmethod def del_plugin_data_by_key(db: Session, plugin_id: str, key: str): - return db.query(PluginData).filter(PluginData.plugin_id == plugin_id, PluginData.key == key).delete() + db.query(PluginData).filter(PluginData.plugin_id == plugin_id, PluginData.key == key).delete() + db.commit() @staticmethod def get_plugin_data_by_plugin_id(db: Session, plugin_id: str): diff --git a/app/db/models/transferhistory.py b/app/db/models/transferhistory.py index 86554582..b004877b 100644 --- a/app/db/models/transferhistory.py +++ b/app/db/models/transferhistory.py @@ -122,3 +122,4 @@ class TransferHistory(Base): "download_hash": download_hash } ) + db.commit()