加入手动指定的开始id
This commit is contained in:
parent
21dc6b1726
commit
7e63b1b7a6
@ -2,6 +2,8 @@ use std::path::Path;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::SaveId;
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct ConfigFile {
|
||||
pub db_url: String,
|
||||
@ -10,6 +12,7 @@ pub struct ConfigFile {
|
||||
pub sqlx_logging: bool,
|
||||
pub worker_count: u32,
|
||||
pub worker_size: u32,
|
||||
pub start_id: SaveId,
|
||||
}
|
||||
|
||||
impl Default for ConfigFile {
|
||||
@ -21,6 +24,7 @@ impl Default for ConfigFile {
|
||||
sqlx_logging: true,
|
||||
worker_count: 10,
|
||||
worker_size: 10,
|
||||
start_id: 1,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,8 @@ pub const TEXT_DATA_MAX_LEN: usize = 1024;
|
||||
|
||||
use model::sea_orm_active_enums::SaveType;
|
||||
|
||||
use crate::db_part::CoverStrategy;
|
||||
|
||||
async fn big_worker(db: sea_orm::DatabaseConnection, work_range: Range<SaveId>) {
|
||||
let client = net::Downloader::default();
|
||||
for work_id in work_range {
|
||||
@ -21,10 +23,22 @@ async fn big_worker(db: sea_orm::DatabaseConnection, work_range: Range<SaveId>)
|
||||
event!(
|
||||
Level::INFO,
|
||||
"{}",
|
||||
format!("Download {} with data len: {}", work_id, file.len()).green()
|
||||
format!(
|
||||
"Download {} with {} data len: {}",
|
||||
work_id,
|
||||
file.type_name(),
|
||||
file.len()
|
||||
)
|
||||
.green()
|
||||
);
|
||||
let save_type = (&file).into();
|
||||
db_part::save_data_to_db(work_id, save_type, file.take_data(), None, &db)
|
||||
db_part::save_data_to_db(
|
||||
work_id,
|
||||
save_type,
|
||||
file.take_data(),
|
||||
Some(CoverStrategy::CoverIfDifferent),
|
||||
&db,
|
||||
)
|
||||
}
|
||||
None => {
|
||||
event!(
|
||||
@ -57,14 +71,14 @@ async fn main() -> anyhow::Result<()> {
|
||||
};
|
||||
|
||||
let db_connect = db_part::connect(&conf).await?;
|
||||
let start_id = db_part::find_max_id(&db_connect).await;
|
||||
let db_max_id = db_part::find_max_id(&db_connect).await;
|
||||
|
||||
event!(Level::INFO, "Starting download from save_id: {}", start_id);
|
||||
event!(Level::INFO, "db max downloaded save_id: {}", db_max_id);
|
||||
|
||||
// 1321469 end
|
||||
let end_id: SaveId = 1321469;
|
||||
|
||||
let mut current_id = start_id;
|
||||
let mut current_id = conf.start_id;
|
||||
|
||||
let batch_size = conf.worker_size;
|
||||
// 10 works
|
||||
@ -90,7 +104,7 @@ async fn main() -> anyhow::Result<()> {
|
||||
}
|
||||
|
||||
if !works.is_empty() {
|
||||
let (result, index, remain) = select_all(works).await;
|
||||
let (_result, _index, remain) = select_all(works).await;
|
||||
works = remain;
|
||||
}
|
||||
}
|
||||
|
@ -47,6 +47,12 @@ impl DownloadFile {
|
||||
DownloadFile::Save(s) => s.len(),
|
||||
}
|
||||
}
|
||||
pub fn type_name(&self) -> &'static str {
|
||||
match self {
|
||||
DownloadFile::Ship(_) => "Ship",
|
||||
DownloadFile::Save(_) => "Save",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&DownloadFile> for SaveType {
|
||||
|
Loading…
Reference in New Issue
Block a user