Skip to content

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

fix(task): canPause 改为派生属性,修复 yt_dlp 任务无法暂停

XiaoYouChR8272d7dc4892
diff --git a/CONTEXT.md b/CONTEXT.md
index 17685695..51f3f7e6 100644
--- a/CONTEXT.md
+++ b/CONTEXT.md
@@ -51,6 +51,12 @@ owns `run()` directly — there is no separate Worker class.
**Subworker**:
A split transfer unit for one byte-range chunk inside an HTTP or FTP step.
+**Pausable**:
+A Task is pausable while its running Step can resume from a breakpoint (for
+transfers, whether the server honours byte-range requests). Pausability is
+derived from resumability at the moment it is read — never stored as separate
+state, because a Step may only learn its resumability after it was created.
+
**Task Files**:
The files and temporary progress state produced by a Task.
diff --git a/features/ftp_pack/task.py b/features/ftp_pack/task.py
index cea95fc1..97dde4ae 100644
--- a/features/ftp_pack/task.py
+++ b/features/ftp_pack/task.py
@@ -123,8 +123,10 @@ class FtpStep(TaskStep):
canUseRangeRequests: bool = False
isAccelerated: bool = False
subworkerCount: int = 8
- def __post_init__(self):
- self.canPause = self.canUseRangeRequests
+
+ @property
+ def canPause(self) -> bool:
+ return self.canUseRangeRequests
@property
def outputPath(self) -> str:
diff --git a/features/http_pack/task.py b/features/http_pack/task.py
index e9011824..9d628ffd 100644
--- a/features/http_pack/task.py
+++ b/features/http_pack/task.py
@@ -64,8 +64,9 @@ class HttpTaskStep(TaskStep):
outputFile: str = ""
subworkers: list[HttpSubworker] = field(default_factory=list, repr=False)
- def __post_init__(self):
- self.canPause = self.canUseRangeRequests
+ @property
+ def canPause(self) -> bool:
+ return self.canUseRangeRequests
def deleteFiles(self):
from app.platform.filesystem import deletePath