能行了?
This commit is contained in:
parent
6c1a914b6a
commit
bbf744fa16
11
Cargo.lock
generated
11
Cargo.lock
generated
@ -435,6 +435,16 @@ version = "1.0.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422"
|
checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "colored"
|
||||||
|
version = "2.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cbf2150cce219b664a8a70df7a1f933836724b503f8a413af9365b4dcc4d90b8"
|
||||||
|
dependencies = [
|
||||||
|
"lazy_static",
|
||||||
|
"windows-sys 0.48.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "const-oid"
|
name = "const-oid"
|
||||||
version = "0.9.6"
|
version = "0.9.6"
|
||||||
@ -2538,6 +2548,7 @@ version = "0.1.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"blake3",
|
"blake3",
|
||||||
|
"colored",
|
||||||
"futures",
|
"futures",
|
||||||
"migration",
|
"migration",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
|
@ -21,3 +21,4 @@ serde = { version = "1.0.204", features = ["serde_derive"] }
|
|||||||
toml = "0.8.15"
|
toml = "0.8.15"
|
||||||
blake3 = "1.5.3"
|
blake3 = "1.5.3"
|
||||||
futures = "0.3.30"
|
futures = "0.3.30"
|
||||||
|
colored = "2.1.0"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use blake3::Hasher;
|
use blake3::Hasher;
|
||||||
use sea_orm::{
|
use sea_orm::{
|
||||||
ActiveModelTrait, ConnectOptions, Database, DatabaseConnection, EntityTrait, IntoActiveModel,
|
ActiveModelTrait, ColumnTrait, ConnectOptions, Database, DatabaseConnection, EntityTrait,
|
||||||
ModelTrait, QueryOrder, QuerySelect, TransactionTrait,
|
IntoActiveModel, ModelTrait, QueryFilter, QueryOrder, QuerySelect, TransactionTrait,
|
||||||
};
|
};
|
||||||
use tracing::{event, Level};
|
use tracing::{event, Level};
|
||||||
|
|
||||||
@ -75,12 +75,11 @@ where
|
|||||||
let cover_strategy = cover_strategy.unwrap_or_default();
|
let cover_strategy = cover_strategy.unwrap_or_default();
|
||||||
let save_type: SaveType = save_type.into();
|
let save_type: SaveType = save_type.into();
|
||||||
let exitst_data: Option<model::main_data::Model> = {
|
let exitst_data: Option<model::main_data::Model> = {
|
||||||
model::main_data::Entity::find_by_id(save_id as i32)
|
model::main_data::Entity::find()
|
||||||
.select_only()
|
.filter(model::main_data::Column::SaveId.eq(save_id as i32))
|
||||||
.column(model::main_data::Column::BlakeHash)
|
|
||||||
.column(model::main_data::Column::Len)
|
|
||||||
.one(db)
|
.one(db)
|
||||||
.await?
|
.await
|
||||||
|
.unwrap_or(None)
|
||||||
};
|
};
|
||||||
if exitst_data.is_some() {
|
if exitst_data.is_some() {
|
||||||
match cover_strategy {
|
match cover_strategy {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
use colored::Colorize;
|
||||||
use futures::future::select_all;
|
use futures::future::select_all;
|
||||||
use std::{ops::Range, path::Path};
|
use std::{ops::Range, path::Path};
|
||||||
use tracing::{event, Level};
|
use tracing::{event, Level};
|
||||||
@ -17,14 +18,26 @@ async fn big_worker(db: sea_orm::DatabaseConnection, work_range: Range<SaveId>)
|
|||||||
for work_id in work_range {
|
for work_id in work_range {
|
||||||
match match client.try_download_as_any(work_id).await {
|
match match client.try_download_as_any(work_id).await {
|
||||||
Some(file) => {
|
Some(file) => {
|
||||||
|
event!(
|
||||||
|
Level::INFO,
|
||||||
|
"{}",
|
||||||
|
format!("Download {} with data len: {}", work_id, file.len()).green()
|
||||||
|
);
|
||||||
let save_type = (&file).into();
|
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(), None, &db)
|
||||||
}
|
}
|
||||||
None => db_part::save_data_to_db(work_id, SaveType::None, "".to_string(), None, &db),
|
None => {
|
||||||
|
event!(
|
||||||
|
Level::INFO,
|
||||||
|
"{}",
|
||||||
|
format!("Download {} with no data", work_id).yellow()
|
||||||
|
);
|
||||||
|
db_part::save_data_to_db(work_id, SaveType::None, "".to_string(), None, &db)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
Ok(_) => event!(Level::INFO, "Save data {} success", work_id),
|
Ok(_) => (),
|
||||||
Err(e) => event!(Level::WARN, "Save data {} failed: {:?}", work_id, e),
|
Err(e) => event!(Level::WARN, "Save data {} failed: {:?}", work_id, e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,12 @@ impl DownloadFile {
|
|||||||
DownloadFile::Save(s) => s,
|
DownloadFile::Save(s) => s,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pub fn len(&self) -> usize {
|
||||||
|
match self {
|
||||||
|
DownloadFile::Ship(s) => s.len(),
|
||||||
|
DownloadFile::Save(s) => s.len(),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&DownloadFile> for SaveType {
|
impl From<&DownloadFile> for SaveType {
|
||||||
|
Loading…
Reference in New Issue
Block a user