The only downloader you need. 下载器的集大成者。
TypeScript asyncasynciobittorentbtcross-platformdownload-managerdownloaderfluent-designftphttp3magnetpyqtpyside6pythonqtquicreactsoftwarestreaming
fix(platform): Windows 下 deletePath 支持删除超长路径与尾空格目录
XiaoYouChR318f415cae4e
diff --git a/app/platform/filesystem.py b/app/platform/filesystem.pyindex 83fe6b43..e327a224 100644--- a/app/platform/filesystem.py+++ b/app/platform/filesystem.py@@ -1,5 +1,6 @@from __future__ import annotations+import osimport reimport shutilimport sys@@ -107,10 +108,15 @@ def findExecutable(installFolder: Path, name: str) -> str:def deletePath(path: Path) -> None:- if path.is_dir() and not path.is_symlink():- shutil.rmtree(path, ignore_errors=True)+ target = path+ if sys.platform == "win32":+ raw = os.path.abspath(path)+ if not raw.startswith("\\\\?\\"):+ target = Path(f"\\\\?\\UNC\\{raw[2:]}" if raw.startswith("\\\\") else f"\\\\?\\{raw}")+ if target.is_dir() and not target.is_symlink():+ shutil.rmtree(target, ignore_errors=True)else:try:- path.unlink(missing_ok=True)+ target.unlink(missing_ok=True)except OSError:passdiff --git a/tests/test_filesystem.py b/tests/test_filesystem.pyindex 854daf74..7b729423 100644--- a/tests/test_filesystem.py+++ b/tests/test_filesystem.py@@ -1,8 +1,9 @@from __future__ import annotations+import sysfrom pathlib import Path-from app.platform.filesystem import isExisting, isFolder+from app.platform.filesystem import deletePath, isExisting, isFolderdef test_probe_unreadable_path_as_missing(tmp_path: Path):@@ -11,3 +12,27 @@ def test_probe_unreadable_path_as_missing(tmp_path: Path):for path in (file / "child", tmp_path / "a\0b"):assert isExisting(path) is Falseassert isFolder(path) is False+++def createFolder(path: Path) -> Path:+ target = Path(f"\\\\?\\{path}") if sys.platform == "win32" else path+ target.mkdir(parents=True)+ return target+++def test_delete_deep_folder_removes_tree(tmp_path: Path):+ root = tmp_path / ("a" * 120)+ deep = createFolder(root / ("b" * 100) / ("c" * 100))+ (deep / "seg.ts").write_bytes(b"data")++ deletePath(root)+ assert not root.exists()+++def test_delete_trailing_space_folder_removes_tree(tmp_path: Path):+ root = tmp_path / "part"+ spaced = createFolder(root / "tmp" / "name ")+ (spaced / "chunk.ts").write_bytes(b"data")++ deletePath(root)+ assert not root.exists()