mirror of
https://github.com/OMGeeky/twba.splitter.git
synced 2026-01-06 19:45:22 +01:00
improve errors (put in path that was not writeable
This commit is contained in:
@@ -97,7 +97,7 @@ impl SplitterClient {
|
||||
let split_info = utils::get_playlist_info(&split_playlist_path).await?;
|
||||
tokio::fs::remove_file(&split_playlist_path)
|
||||
.await
|
||||
.map_err(SplitterError::Write)?;
|
||||
.map_err(|e| SplitterError::Write(split_playlist_path.clone(), e))?;
|
||||
trace!(
|
||||
"total duration: {} in {} parts",
|
||||
split_info.total_duration.to_string(),
|
||||
@@ -110,7 +110,7 @@ impl SplitterClient {
|
||||
debug!("removing original file: {:?}", input_path);
|
||||
tokio::fs::remove_file(&input_path)
|
||||
.await
|
||||
.map_err(SplitterError::Write)?;
|
||||
.map_err(|e| SplitterError::Write(input_path.clone(), e))?;
|
||||
|
||||
let duration = Instant::now().duration_since(start_time);
|
||||
info!("Done Splitting. Whole operation took: {:?}", duration);
|
||||
|
||||
@@ -84,7 +84,7 @@ async fn join_last_two_parts(input_parts: &mut PlaylistInfo, base_folder: &Path)
|
||||
),
|
||||
)
|
||||
.await
|
||||
.map_err(SplitterError::Write)?;
|
||||
.map_err(|e| SplitterError::Write(join_txt_path.clone(), e))?;
|
||||
|
||||
run_ffmpeg_concat(
|
||||
join_txt_path
|
||||
@@ -101,22 +101,26 @@ async fn join_last_two_parts(input_parts: &mut PlaylistInfo, base_folder: &Path)
|
||||
"removing files: {:?}, {:?}, {:?}",
|
||||
second_last_part.path, last_part.path, join_txt_path
|
||||
);
|
||||
tokio::fs::remove_file(last_part.path)
|
||||
trace!("removing file: {:?}", last_part.path);
|
||||
tokio::fs::remove_file(&last_part.path)
|
||||
.await
|
||||
.map_err(SplitterError::Write)?;
|
||||
.map_err(|e| SplitterError::Write(last_part.path, e))?;
|
||||
trace!("removing file: {:?}", second_last_part.path);
|
||||
tokio::fs::remove_file(&second_last_part.path)
|
||||
.await
|
||||
.map_err(SplitterError::Write)?;
|
||||
tokio::fs::remove_file(join_txt_path)
|
||||
.map_err(|e| SplitterError::Write(second_last_part.path.clone(), e))?;
|
||||
trace!("removing file: {:?}", join_txt_path);
|
||||
tokio::fs::remove_file(&join_txt_path)
|
||||
.await
|
||||
.map_err(SplitterError::Write)?;
|
||||
.map_err(|e| SplitterError::Write(join_txt_path.clone(), e))?;
|
||||
debug!(
|
||||
"renaming file: {:?} to {:?}",
|
||||
join_out_tmp_path, second_last_part.path
|
||||
);
|
||||
tokio::fs::rename(join_out_tmp_path, &second_last_part.path)
|
||||
.await
|
||||
.map_err(SplitterError::Write)?;
|
||||
.map_err(|e| SplitterError::Write(second_last_part.path.clone(), e))?;
|
||||
debug!("joined last two parts together");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ pub enum SplitterError {
|
||||
#[error("Could not read from filesystem: {0:?}")]
|
||||
Read(#[source] io::Error),
|
||||
#[error("Could not write to filesystem: {0:?}")]
|
||||
Write(#[source] io::Error),
|
||||
Write(PathBuf, #[source] io::Error),
|
||||
|
||||
#[error("Path could not be canonicalized: {0:?}")]
|
||||
Canonicalize(#[source] io::Error),
|
||||
|
||||
Reference in New Issue
Block a user