The only downloader you need. 下载器的集大成者。
TypeScript asyncasynciobittorentbtcross-platformdownload-managerdownloaderfluent-designftphttp3magnetpyqtpyside6pythonqtquicreactsoftwarestreaming
fix(app): 优化文件系统检测和 macOS 稀疏文件创建逻辑
XiaoYouChRdf541aea8e08
diff --git a/app/common/download_task.py b/app/common/download_task.pyindex 94ed9a4a..18d06601 100644--- a/app/common/download_task.py+++ b/app/common/download_task.py@@ -146,12 +146,13 @@ class DownloadTask(QThread):self.fileName = self.fileName[:255]filePath = Path(f"{self.filePath}/{self.fileName}")- filePath.touch()- try:- createSparseFile(filePath)- except Exception as e:- logger.warning("创建稀疏文件失败", repr(e))+ if not filePath.exists():+ filePath.touch()+ try:+ createSparseFile(filePath)+ except Exception as e:+ logger.warning("创建稀疏文件失败", repr(e))# 任务初始化完成if self.ableToParallelDownload:diff --git a/app/common/methods.py b/app/common/methods.pyindex c760e744..efac2caa 100644--- a/app/common/methods.py+++ b/app/common/methods.py@@ -338,8 +338,30 @@ def isSparseSupported(filePath: Path) -> bool:fs_type = os.statvfs(filePath).f_basetypereturn fs_type in ('ext4', 'xfs', 'btrfs', 'zfs')elif sys.platform == "darwin": # macOS- fs_info = os.statvfs(filePath).f_fstypename- return fs_info in ('apfs', 'hfs')+ df_output = subprocess.check_output(+ ["df", "-h", filePath],+ stderr=subprocess.STDOUT,+ universal_newlines=True+ ).splitlines()++ # 提取设备节点 (第二行第二列)+ if len(df_output) < 2:+ return False+ device_node = df_output[1].split()[0]++ # 获取挂载信息+ mount_output = subprocess.check_output(+ ["mount"],+ universal_newlines=True+ )++ # 解析文件系统类型+ for line in mount_output.splitlines():+ if line.startswith(device_node):+ parts = line.split()+ for part in parts:+ if part.startswith("(") and "," in part:+ return part.strip("(),").split(",")[0] in ('apfs', 'hfs')return Falseexcept Exception as e:logger.warning(f"文件系统检测失败: {repr(e)}")