From 5788520401339c1a010b6897555c319d09e2225a Mon Sep 17 00:00:00 2001 From: jxxghp Date: Thu, 8 May 2025 10:09:24 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E9=98=BF=E9=87=8C=E4=BA=91=E7=9B=98?= =?UTF-8?q?=E4=BC=9A=E8=AF=9D=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/modules/filemanager/storages/alipan.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/modules/filemanager/storages/alipan.py b/app/modules/filemanager/storages/alipan.py index ead220f7..4190e943 100644 --- a/app/modules/filemanager/storages/alipan.py +++ b/app/modules/filemanager/storages/alipan.py @@ -27,6 +27,10 @@ class NoCheckInException(Exception): pass +class SessionInvalidException(Exception): + pass + + class AliPan(StorageBase, metaclass=Singleton): """ 阿里云盘相关操作 @@ -185,7 +189,7 @@ class AliPan(StorageBase, metaclass=Singleton): 确认登录后,获取相关token """ if not self._auth_state: - raise Exception("【阿里云盘】请先生成二维码") + raise SessionInvalidException("【阿里云盘】请先生成二维码") resp = self.session.post( f"{self.base_url}/oauth/access_token", json={ @@ -196,7 +200,7 @@ class AliPan(StorageBase, metaclass=Singleton): } ) if resp is None: - raise Exception("【阿里云盘】获取 access_token 失败") + raise SessionInvalidException("【阿里云盘】获取 access_token 失败") result = resp.json() if result.get("code"): raise Exception(f"【阿里云盘】{result.get('code')} - {result.get('message')}!") @@ -207,7 +211,7 @@ class AliPan(StorageBase, metaclass=Singleton): 刷新access_token """ if not refresh_token: - raise Exception("【阿里云盘】会话失效,请重新扫码登录!") + raise SessionInvalidException("【阿里云盘】会话失效,请重新扫码登录!") resp = self.session.post( f"{self.base_url}/oauth/access_token", json={ @@ -650,7 +654,7 @@ class AliPan(StorageBase, metaclass=Singleton): """ class TqdmToLogger(io.StringIO): - def write(s, buf): # noqa + def write(s, buf): # noqa buf = buf.strip('\r\n\t ') if buf: logger.info(buf) @@ -1012,3 +1016,5 @@ class AliPan(StorageBase, metaclass=Singleton): ) except NoCheckInException: return None + except SessionInvalidException: + return None