Split files differently
This commit is contained in:
parent
4de4bb6e3d
commit
2e029df64d
|
@ -611,12 +611,13 @@ pub async fn upload_worker(
|
|||
};
|
||||
let total_size = file.seek(SeekFrom::End(0)).await.unwrap();
|
||||
file.seek(SeekFrom::Start(0)).await.unwrap();
|
||||
let parts = (total_size as f64 / (2000.0 * 1024.0 * 1024.0)).ceil() as usize;
|
||||
for i in 0..parts {
|
||||
let filename = if parts == 1 {
|
||||
video_filename.clone()
|
||||
} else {
|
||||
let mut sent_size = 0;
|
||||
let split = total_size > 2000 * 1024 * 1024;
|
||||
for i in 0.. {
|
||||
let filename = if split {
|
||||
format!("{}.part{:02}", &video_filename, i)
|
||||
} else {
|
||||
video_filename.clone()
|
||||
};
|
||||
let message = tclient
|
||||
.send_message(
|
||||
|
@ -666,7 +667,7 @@ pub async fn upload_worker(
|
|||
}
|
||||
};
|
||||
}
|
||||
let mut size = total_size - file.stream_position().await.unwrap();
|
||||
let mut size = total_size - sent_size;
|
||||
if size > 2000 * 1024 * 1024 {
|
||||
size = 2000 * 1024 * 1024;
|
||||
}
|
||||
|
@ -717,6 +718,7 @@ pub async fn upload_worker(
|
|||
}
|
||||
}
|
||||
};
|
||||
sent_size = file.stream_position().await.unwrap();
|
||||
if let Ok(mut message) = message {
|
||||
if let Err(err) = message.delete().await {
|
||||
eprintln!("Failed to delete uploading message: {:?}", err);
|
||||
|
@ -761,6 +763,9 @@ pub async fn upload_worker(
|
|||
};
|
||||
}
|
||||
}
|
||||
if sent_size >= total_size {
|
||||
break;
|
||||
}
|
||||
}
|
||||
drop(file);
|
||||
if success {
|
||||
|
|
Loading…
Reference in New Issue