mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-03-20 03:57:30 +08:00
perf: 使用deque优化绿联媒体库遍历队列性能
This commit is contained in:
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user