feat: 支持设置创建下载任务后是否自动开始

This commit is contained in:
lanyeeee
2026-02-01 08:41:27 +08:00
parent f09e8cfc49
commit fa5be81fb8
6 changed files with 22 additions and 6 deletions

View File

@@ -43,6 +43,7 @@ pub struct Config {
pub chunk_download_interval_sec: u64,
pub danmaku_config: CanvasConfig,
pub file_exist_action: FileExistAction,
pub auto_start_download_task: bool,
}
impl Config {
@@ -153,6 +154,7 @@ impl Config {
chunk_download_interval_sec: 0,
danmaku_config: CanvasConfig::default(),
file_exist_action: FileExistAction::Overwrite,
auto_start_download_task: true,
}
}
}

View File

@@ -98,7 +98,14 @@ impl DownloadTask {
tracing::error!(err_title, message = string_chain);
}
let (state_sender, _) = watch::channel(DownloadTaskState::Pending);
let auto_start = app.get_config().read().auto_start_download_task;
let init_state = if auto_start {
DownloadTaskState::Pending
} else {
DownloadTaskState::Paused
};
let (state_sender, _) = watch::channel(init_state);
let (restart_sender, _) = watch::channel(());
let (cancel_sender, _) = watch::channel(());
let (delete_sender, _) = watch::channel(());