mirror of
https://github.com/amtoaer/bili-sync.git
synced 2026-09-08 17:09:14 +08:00
feat: 支持禁用凭证检查刷新任务,由用户自行维护 credential 有效性 (#560)
This commit is contained in:
@@ -13,6 +13,9 @@ pub struct Args {
|
|||||||
|
|
||||||
#[arg(short, long, default_value = "None,bili_sync=info", env = "RUST_LOG")]
|
#[arg(short, long, default_value = "None,bili_sync=info", env = "RUST_LOG")]
|
||||||
pub log_level: String,
|
pub log_level: String,
|
||||||
|
|
||||||
|
#[arg(short, long, env = "DISABLE_CREDENTIAL_REFRESH")]
|
||||||
|
pub disable_credential_refresh: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
mod built_info {
|
mod built_info {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use tokio_cron_scheduler::{Job, JobScheduler};
|
|||||||
|
|
||||||
use crate::adapter::VideoSource;
|
use crate::adapter::VideoSource;
|
||||||
use crate::bilibili::{self, BiliClient, BiliError};
|
use crate::bilibili::{self, BiliClient, BiliError};
|
||||||
use crate::config::{Config, TEMPLATE, Trigger, VersionedConfig};
|
use crate::config::{ARGS, Config, TEMPLATE, Trigger, VersionedConfig};
|
||||||
use crate::utils::model::get_enabled_video_sources;
|
use crate::utils::model::get_enabled_video_sources;
|
||||||
use crate::utils::notify::error_and_notify;
|
use crate::utils::notify::error_and_notify;
|
||||||
use crate::workflow::process_video_source;
|
use crate::workflow::process_video_source;
|
||||||
@@ -109,6 +109,9 @@ impl DownloadTaskManager {
|
|||||||
// 读取初始配置
|
// 读取初始配置
|
||||||
let mut rx = VersionedConfig::get().subscribe();
|
let mut rx = VersionedConfig::get().subscribe();
|
||||||
let initial_config = rx.borrow_and_update().clone();
|
let initial_config = rx.borrow_and_update().clone();
|
||||||
|
if ARGS.disable_credential_refresh {
|
||||||
|
warn!("已禁用凭据检查与刷新任务,bili-sync 将不会自动检查刷新 Credential,需要用户自行维护");
|
||||||
|
} else {
|
||||||
// 初始化凭据检查与刷新任务,该任务必须成功,否则直接退出
|
// 初始化凭据检查与刷新任务,该任务必须成功,否则直接退出
|
||||||
sched
|
sched
|
||||||
.lock()
|
.lock()
|
||||||
@@ -119,6 +122,7 @@ impl DownloadTaskManager {
|
|||||||
DownloadTaskManager::check_and_refresh_credential_task(cx.clone()),
|
DownloadTaskManager::check_and_refresh_credential_task(cx.clone()),
|
||||||
)?)
|
)?)
|
||||||
.await?;
|
.await?;
|
||||||
|
}
|
||||||
// 初始化并添加视频下载任务,将任务 ID 保存到 TaskManager 中
|
// 初始化并添加视频下载任务,将任务 ID 保存到 TaskManager 中
|
||||||
let video_task_id = async {
|
let video_task_id = async {
|
||||||
let job_run = DownloadTaskManager::download_video_task(cx.clone());
|
let job_run = DownloadTaskManager::download_video_task(cx.clone());
|
||||||
|
|||||||
Reference in New Issue
Block a user