mirror of
https://github.com/amtoaer/bili-sync.git
synced 2026-09-09 01:17:13 +08:00
fix: 确保无论视频下载结果如何,都在最终删除临时文件 (#159)
This commit is contained in:
@@ -51,8 +51,6 @@ impl Downloader {
|
|||||||
_ => Err(anyhow!("ffmpeg error")),
|
_ => Err(anyhow!("ffmpeg error")),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
let _ = fs::remove_file(video_path).await;
|
|
||||||
let _ = fs::remove_file(audio_path).await;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -485,9 +485,14 @@ pub async fn fetch_page_video(
|
|||||||
page_path.with_extension("tmp_video"),
|
page_path.with_extension("tmp_video"),
|
||||||
page_path.with_extension("tmp_audio"),
|
page_path.with_extension("tmp_audio"),
|
||||||
);
|
);
|
||||||
|
let res = {
|
||||||
downloader.fetch(video_stream.url(), &tmp_video_path).await?;
|
downloader.fetch(video_stream.url(), &tmp_video_path).await?;
|
||||||
downloader.fetch(audio_stream.url(), &tmp_audio_path).await?;
|
downloader.fetch(audio_stream.url(), &tmp_audio_path).await?;
|
||||||
downloader.merge(&tmp_video_path, &tmp_audio_path, &page_path).await?;
|
downloader.merge(&tmp_video_path, &tmp_audio_path, &page_path).await
|
||||||
|
};
|
||||||
|
let _ = fs::remove_file(tmp_video_path).await;
|
||||||
|
let _ = fs::remove_file(tmp_audio_path).await;
|
||||||
|
res?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Reference in New Issue
Block a user