update compression level and logging compression time
This commit is contained in:
1 parent
5817bfcd46
commit
27bdcf41b0
1 file changed
+7
-3
@@ -3,8 +3,9 @@ use crate::notification::NotificationData::{
|
||||
CompressError, OpenFileError, PermissionDenied, WebApiUnavailable,
|
||||
};
|
||||
use crate::notification::{MaybeError, NotificationData};
|
||||
use log::info;
|
||||
use log::{debug, info};
|
||||
use std::io;
|
||||
use std::time::Instant;
|
||||
use tokio::fs::{File, OpenOptions, remove_file};
|
||||
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
||||
use zstd::{DEFAULT_COMPRESSION_LEVEL, Decoder, Encoder};
|
||||
@@ -37,10 +38,13 @@ pub async fn send_data(id: String) -> MaybeError {
|
||||
}
|
||||
|
||||
fn compress(data: Vec<u8>) -> Result<Vec<u8>, NotificationData> {
|
||||
let time = Instant::now();
|
||||
let mut encoder =
|
||||
Encoder::new(Vec::new(), DEFAULT_COMPRESSION_LEVEL).map_err(|_| CompressError)?;
|
||||
Encoder::new(Vec::new(), 17).map_err(|_| CompressError)?;
|
||||
io::copy(&mut &data[..], &mut encoder).map_err(|_| PermissionDenied)?;
|
||||
encoder.finish().map_err(|_| CompressError)
|
||||
let result = encoder.finish().map_err(|_| CompressError);
|
||||
debug!("Compress time: {:?}", time.elapsed());
|
||||
result
|
||||
}
|
||||
|
||||
pub async fn load_data(id: String, temp: bool) -> MaybeError {
|
||||
|
||||
Reference in new issue
Block a user