improve errors (put in path that was not writeable

This commit is contained in:
OMGeeky
2024-05-02 22:26:03 +02:00
parent f70bd3e821
commit 4cd168409f
3 changed files with 14 additions and 10 deletions

View File

@@ -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);

View File

@@ -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(())
}

View File

@@ -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),