mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 22:42:25 -04:00
ignore errors when file to delete is already gone
May be marked as pending upload or in media check screen, then removed by user.
This commit is contained in:
parent
df201c164f
commit
1b0e8485fd
1 changed files with 9 additions and 0 deletions
|
@ -313,6 +313,15 @@ where
|
||||||
let src_path = media_folder.join(file.as_ref());
|
let src_path = media_folder.join(file.as_ref());
|
||||||
let dst_path = trash_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
|
// move file to trash, clobbering any existing file with the same name
|
||||||
fs::rename(&src_path, &dst_path)?;
|
fs::rename(&src_path, &dst_path)?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue