mirror of
https://github.com/Bluemangoo/sekai-unpacker.git
synced 2026-09-20 00:06:52 +08:00
fix ram
This commit is contained in:
+1
-2
@@ -183,7 +183,6 @@ async fn main() -> anyhow::Result<()> {
|
||||
let liveness_tx = liveness_tx.clone();
|
||||
join_set.spawn(async move {
|
||||
let _guard = liveness_tx;
|
||||
let mut inner_set = JoinSet::new();
|
||||
loop {
|
||||
if cancel_token.is_cancelled() {
|
||||
return;
|
||||
@@ -205,7 +204,7 @@ async fn main() -> anyhow::Result<()> {
|
||||
let local_manifest = local_manifest.clone();
|
||||
let signal = signal.clone();
|
||||
|
||||
inner_set.spawn(async move {
|
||||
tokio::spawn(async move {
|
||||
loop {
|
||||
if client.get_client().await.is_err() {
|
||||
return;
|
||||
|
||||
+14
-5
@@ -121,11 +121,6 @@ pub async fn run_main(
|
||||
match r {
|
||||
Ok(Ok(())) => cnt.inc_success(),
|
||||
Ok(Err(e)) => {
|
||||
if e.to_string()
|
||||
.contains("Session did not reconnect within 15s")
|
||||
{
|
||||
return Err(anyhow!(e));
|
||||
}
|
||||
error!("{}", e);
|
||||
cnt.inc_failure()
|
||||
}
|
||||
@@ -163,12 +158,21 @@ pub async fn run_side(
|
||||
let n = p1.concurrent.unwrap_or(5);
|
||||
let semaphore = Arc::new(Semaphore::new(n));
|
||||
let mut join_set = JoinSet::new();
|
||||
|
||||
let cancel_token = CancellationToken::new();
|
||||
while let Some(task) = queue.try_pop() {
|
||||
if cancel_token.is_cancelled() {
|
||||
break;
|
||||
}
|
||||
let permit = semaphore.clone().acquire_owned().await?;
|
||||
if cancel_token.is_cancelled() {
|
||||
break;
|
||||
}
|
||||
let client = client.clone();
|
||||
let id = id.clone();
|
||||
let local_manifest = manifest.clone();
|
||||
let p1 = p1.clone();
|
||||
let cancel_token = cancel_token.clone();
|
||||
|
||||
join_set.spawn(async move {
|
||||
let guard = task;
|
||||
@@ -185,6 +189,11 @@ pub async fn run_side(
|
||||
let mut retry_conn = client.get_client().await?;
|
||||
result = download(&mut retry_conn, &req, &p1).await;
|
||||
}
|
||||
if let Err(e) = &result
|
||||
&& e.downcast_ref::<h2::Error>().is_some()
|
||||
{
|
||||
cancel_token.cancel();
|
||||
}
|
||||
result?;
|
||||
|
||||
local_manifest
|
||||
|
||||
Reference in New Issue
Block a user