From 1b0e8485fd7905ab0f6cdd3af0d78393c6164743 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Tue, 11 Feb 2020 19:34:01 +1000 Subject: [PATCH] ignore errors when file to delete is already gone May be marked as pending upload or in media check screen, then removed by user. --- rslib/src/media/files.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/rslib/src/media/files.rs b/rslib/src/media/files.rs index 0a1070bc1..17090b2f0 100644 --- a/rslib/src/media/files.rs +++ b/rslib/src/media/files.rs @@ -313,6 +313,15 @@ where let src_path = media_folder.join(file.as_ref()); let dst_path = trash_folder.join(file.as_ref()); + // if the file doesn't exist, nothing to do + if let Err(e) = fs::metadata(&src_path) { + if e.kind() == io::ErrorKind::NotFound { + return Ok(()); + } else { + return Err(e.into()); + } + } + // move file to trash, clobbering any existing file with the same name fs::rename(&src_path, &dst_path)?;