Skip to content

The only downloader you need. 下载器的集大成者。

feat(download): 支持windows稀疏文件创建并添加相应日志提示

AlphaQian7da1531b8b75
diff --git a/app/common/download_task.py b/app/common/download_task.py
index f6684209..6473914a 100644
--- a/app/common/download_task.py
+++ b/app/common/download_task.py
@@ -146,10 +146,14 @@ class DownloadTask(QThread):
if len(self.fileName) > 255:
self.fileName = self.fileName[:255]
- if sys.platform == "win32":
- system(f'fsutil file createnew "{self.filePath}/{self.fileName}" {self.fileSize}')
- else:
- Path(f"{self.filePath}/{self.fileName}").touch()
+ Path(f"{self.filePath}/{self.fileName}").touch()
+ _ = True
+ if _:#稀疏文件
+ logger.info("稀疏文件已启用")
+ if sys.platform == "win32":
+ print(system(f'fsutil sparse setflag "{self.filePath}/{self.fileName}"'))
+ else:
+ logger.warning("当前系统暂时不支持稀疏文件")
# 任务初始化完成
if self.ableToParallelDownload: