(Try to) Fix calculating file size

This commit is contained in:
blank X 2021-06-21 19:55:33 +07:00
parent d109e3f034
commit e5c9ff3aed
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
1 changed files with 1 additions and 2 deletions

View File

@ -612,14 +612,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;
let current_position = 0;
for i in 0..parts {
let filename = if parts == 1 {
video_filename.clone()
} else {
format!("{}.part{:02}", &video_filename, i)
};
let mut size = total_size - current_position;
let mut size = file.stream_position().await.unwrap();
if size > 2000 * 1024 * 1024 {
size = 2000 * 1024 * 1024;
}