feat: 支持手动编辑某个视频、分页状态,优化部分代码 (#355)

This commit is contained in:
ᴀᴍᴛᴏᴀᴇʀ
2025-06-06 07:39:17 +08:00
committed by GitHub
parent c0ed37750f
commit 65a047b0fa
20 changed files with 670 additions and 31 deletions

View File

@@ -5,7 +5,7 @@ pub mod model;
pub mod nfo;
pub mod signal;
pub mod status;
pub mod validation;
use tracing_subscriber::util::SubscriberInitExt;
pub fn init_logger(log_level: &str) {

View File

@@ -1,5 +1,6 @@
use crate::error::ExecutionStatus;
pub static STATUS_NOT_STARTED: u32 = 0b000;
pub(super) static STATUS_MAX_RETRY: u32 = 0b100;
pub static STATUS_OK: u32 = 0b111;
pub static STATUS_COMPLETED: u32 = 1 << 31;
@@ -34,7 +35,7 @@ impl<const N: usize> Status<N> {
for i in 0..N {
let status = self.get_status(i);
if !(status < STATUS_MAX_RETRY || status == STATUS_OK) {
self.set_status(i, 0);
self.set_status(i, STATUS_NOT_STARTED);
changed = true;
}
}

View File

@@ -0,0 +1,13 @@
use validator::ValidationError;
use crate::utils::status::{STATUS_NOT_STARTED, STATUS_OK};
pub fn validate_status_value(value: u32) -> Result<(), ValidationError> {
if value == STATUS_OK || value == STATUS_NOT_STARTED {
Ok(())
} else {
Err(ValidationError::new(
"status_value must be either STATUS_OK or STATUS_NOT_STARTED",
))
}
}