forked from Zynh0722/nyazoom
we're zipping baby!!!
parent
e8f7edb117
commit
807334f29b
|
@ -1,2 +1,3 @@
|
||||||
/target
|
/target
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
/.cache
|
||||||
|
|
26
src/main.rs
26
src/main.rs
|
@ -1,7 +1,7 @@
|
||||||
|
use std::io;
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
use std::path::{Component, Path};
|
use std::path::{Component, Path};
|
||||||
use std::sync::Arc;
|
use std::sync::{Arc, Mutex};
|
||||||
use std::io;
|
|
||||||
|
|
||||||
use axum::body::Bytes;
|
use axum::body::Bytes;
|
||||||
use axum::http::StatusCode;
|
use axum::http::StatusCode;
|
||||||
|
@ -19,7 +19,6 @@ use rand::rngs::SmallRng;
|
||||||
use rand::SeedableRng;
|
use rand::SeedableRng;
|
||||||
use tokio::fs::File;
|
use tokio::fs::File;
|
||||||
use tokio::io::BufWriter;
|
use tokio::io::BufWriter;
|
||||||
use tokio::sync::Mutex;
|
|
||||||
use tokio::task::{spawn_blocking, JoinHandle};
|
use tokio::task::{spawn_blocking, JoinHandle};
|
||||||
use tokio_util::io::StreamReader;
|
use tokio_util::io::StreamReader;
|
||||||
use tower_http::{limit::RequestBodyLimitLayer, services::ServeDir, trace::TraceLayer};
|
use tower_http::{limit::RequestBodyLimitLayer, services::ServeDir, trace::TraceLayer};
|
||||||
|
@ -165,9 +164,9 @@ where
|
||||||
let path = entry.path();
|
let path = entry.path();
|
||||||
|
|
||||||
// This feels terribly wrong
|
// This feels terribly wrong
|
||||||
spawn_blocking(|| async move {
|
spawn_blocking(move || {
|
||||||
let mut file = std::fs::File::open(path).unwrap();
|
let mut file = std::fs::File::open(path).unwrap();
|
||||||
let mut writer = writer.lock().await;
|
let mut writer = writer.lock().unwrap();
|
||||||
|
|
||||||
let options = zip::write::FileOptions::default()
|
let options = zip::write::FileOptions::default()
|
||||||
.compression_method(zip::CompressionMethod::DEFLATE);
|
.compression_method(zip::CompressionMethod::DEFLATE);
|
||||||
|
@ -178,9 +177,22 @@ where
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
join_all(zip_handles).await;
|
// let out: Vec<u64> = join_all(zip_handles)
|
||||||
|
// .await
|
||||||
|
// .iter()
|
||||||
|
// .map(|v| { v.unwrap().join() })
|
||||||
|
// .collect();
|
||||||
|
|
||||||
writer.lock().await.finish()?;
|
join_all(zip_handles)
|
||||||
|
.await
|
||||||
|
.iter()
|
||||||
|
.map(|v| {
|
||||||
|
v.as_ref().unwrap().as_ref().unwrap()
|
||||||
|
})
|
||||||
|
.for_each(|bytes| tracing::debug!("bytes written {bytes}"));
|
||||||
|
|
||||||
|
|
||||||
|
writer.lock().unwrap().finish()?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue