1
0
mirror of https://github.com/Bluemangoo/sekai-unpacker.git synced 2026-05-06 20:44:47 +08:00

fix tcp server wait

This commit is contained in:
Bluemangoo 2026-04-23 19:00:05 +08:00
parent 59c50d5e08
commit e00b25b6c7
Signed by: Bluemangoo
GPG Key ID: F2F7E46880A1C4CF
2 changed files with 45 additions and 12 deletions

View File

@ -200,6 +200,16 @@ async fn main() -> anyhow::Result<()> {
if error.to_string().contains(REGION_NOT_FOUND) {
return;
}
if error
.to_string()
.contains("Session did not reconnect within 15s")
{
error!(
"Session lost for profile {}. Waiting for a fresh tunnel endpoint...",
profile.0
);
return;
}
error!("{}", error);
}
_ => {}
@ -251,6 +261,16 @@ async fn main() -> anyhow::Result<()> {
.await;
}
Err(error) => {
if error
.to_string()
.contains("Session did not reconnect within 15s")
{
error!(
"Session lost for profile {}. Reconnecting tunnel...",
profile.0
);
break;
}
error!("{}", error);
}
_ => {}

View File

@ -2,6 +2,7 @@ use crate::config::Profile;
use crate::http::{close, download, sync};
use common::http::{CloseRequest, DownloadRequest};
use communicator::ClientManager;
use anyhow::anyhow;
use log::{error, info};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
@ -64,30 +65,42 @@ pub async fn run(
id: id.clone(),
task: task.clone(),
};
let result = download(&mut client.get_client().await.unwrap(), &req, &p1).await;
if let Err(e) = result
&& let Some(_) = e.downcast_ref::<h2::Error>()
let mut conn = client.get_client().await?;
let mut result = download(&mut conn, &req, &p1).await;
if let Err(e) = &result
&& e.downcast_ref::<h2::Error>().is_some()
{
download(&mut client.get_client().await.unwrap(), &req, &p1)
.await
.unwrap();
let mut retry_conn = client.get_client().await?;
result = download(&mut retry_conn, &req, &p1).await;
}
result?;
local_manifest
.add_bundle(task.bundle_path.clone(), task.bundle_hash.clone())
.await
.unwrap();
?;
drop(permit);
Ok::<(), anyhow::Error>(())
});
}
let mut succeed = 0;
let mut failed = 0;
while let Some(r) = join_set.join_next().await {
if let Err(e) = r {
error!("{}", e);
failed += 1;
} else {
succeed += 1;
match r {
Ok(Ok(())) => {
succeed += 1;
}
Ok(Err(e)) => {
if e.to_string().contains("Session did not reconnect within 15s") {
return Err(anyhow!(e));
}
error!("{}", e);
failed += 1;
}
Err(e) => {
error!("{}", e);
failed += 1;
}
}
}
local_manifest.save().await?;