diff --git a/app/modules/filemanager/storages/u115.py b/app/modules/filemanager/storages/u115.py index 6fc940c7..e68ea972 100644 --- a/app/modules/filemanager/storages/u115.py +++ b/app/modules/filemanager/storages/u115.py @@ -225,7 +225,7 @@ class U115Pan(StorageBase, metaclass=WeakSingleton): retry_times = kwargs.pop("retry_limit", 5) # qps 速率限制 - if endpoint in self.qps_limiter.keys(): + if endpoint in self.qps_limiter: self.qps_limiter[endpoint].acquire() try: @@ -509,7 +509,7 @@ class U115Pan(StorageBase, metaclass=WeakSingleton): return schemas.FileItem( storage=self.schema.value, fileid=str(info_resp["file_id"]), - path=str(target_path) + path=target_path.as_posix() + ("/" if info_resp["file_category"] == "0" else ""), type="file" if info_resp["file_category"] == "1" else "dir", name=info_resp["file_name"], diff --git a/app/utils/limit.py b/app/utils/limit.py index 47008fba..e9a90acd 100644 --- a/app/utils/limit.py +++ b/app/utils/limit.py @@ -400,9 +400,10 @@ class QpsRateLimiter: """ 获取调用许可,阻塞直到满足速率限制 """ + sleep_duration = 0 with self.lock: now = time.monotonic() - wait_time = self.next_call_time - now - if wait_time > 0: - time.sleep(wait_time) + sleep_duration = self.next_call_time - now self.next_call_time = max(now, self.next_call_time) + self.interval + if sleep_duration > 0: + time.sleep(sleep_duration)