feat: 支持手动编辑某个视频、分页状态,优化部分代码 (#355)
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
13
crates/bili_sync/src/utils/validation.rs
Normal file
13
crates/bili_sync/src/utils/validation.rs
Normal 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",
|
||||
))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user