Merge pull request #1 from baozaodetudou/v2

perf: 使用deque优化绿联媒体库遍历队列性能
This commit is contained in:
逗猫
2026-02-28 22:15:39 +08:00
committed by GitHub

View File

@@ -1,4 +1,5 @@
import hashlib import hashlib
from collections import deque
from datetime import datetime from datetime import datetime
from pathlib import Path from pathlib import Path
from typing import Any, Dict, Generator, List, Mapping, Optional, Union from typing import Any, Dict, Generator, List, Mapping, Optional, Union
@@ -767,12 +768,12 @@ class Ugreen:
if not self._api or not root_path: if not self._api or not root_path:
return return
queue: List[str] = [root_path] queue = deque([root_path])
visited: set[str] = set() visited: set[str] = set()
max_paths = 20000 max_paths = 20000
while queue and len(visited) < max_paths: while queue and len(visited) < max_paths:
current_path = queue.pop(0) current_path = queue.popleft()
if current_path in visited: if current_path in visited:
continue continue
visited.add(current_path) visited.add(current_path)