mirror of
https://github.com/OMGeeky/twitch_data.git
synced 2025-12-26 16:27:24 +01:00
use copy instead of reading the whole file into memory and then writing all
this should call read & write repeatedly until the whole file is copied into the target file (at the current position)
This commit is contained in:
@@ -712,12 +712,11 @@ pub async fn convert_ts_to_mp4(video_mp4: &PathBuf, video_ts: &PathBuf) -> Resul
|
||||
pub async fn combine_parts_into_single_ts(files: Vec<PathBuf>, video_ts: &PathBuf) -> Result<()> {
|
||||
debug!("combining all parts of video");
|
||||
debug!("part amount: {}", files.len());
|
||||
let mut video_ts_file = tokio::fs::File::create(&video_ts).await?;
|
||||
let mut video_ts_file = File::create(&video_ts).await?;
|
||||
for file_path in &files {
|
||||
debug!("{:?}", file_path.file_name());
|
||||
let file = tokio::fs::read(&file_path).await?;
|
||||
trace!("size of file: {}", file.len());
|
||||
video_ts_file.write_all(&file).await?;
|
||||
let mut file = File::open(&file_path).await?;
|
||||
tokio::io::copy(&mut file, &mut video_ts_file).await?;
|
||||
tokio::fs::remove_file(&file_path).await?;
|
||||
}
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user