From 18cd8412463dd8f231b605855c54e779a355d8fa Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Tue, 10 Mar 2020 09:29:36 +1000 Subject: [PATCH] don't try to read file data when file marked as a deletion If the user hadn't used the media check to clean up files with invalid names on disk, the long filename would break the 'automatically rename long filenames when syncing' functionality, causing the original long filename to be uploaded to AnkiWeb as an addition instead of a deletion --- rslib/src/media/sync.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/rslib/src/media/sync.rs b/rslib/src/media/sync.rs index c6cc551d5..973aa1d6d 100644 --- a/rslib/src/media/sync.rs +++ b/rslib/src/media/sync.rs @@ -712,13 +712,18 @@ fn zip_files<'a>( break; } - let file_data = match data_for_file(media_folder, &file.fname) { - Ok(data) => data, - Err(e) => { - debug!(log, "error accessing {}: {}", &file.fname, e); - invalid_entries.push(&file.fname); - continue; + let file_data = if file.sha1.is_some() { + match data_for_file(media_folder, &file.fname) { + Ok(data) => data, + Err(e) => { + debug!(log, "error accessing {}: {}", &file.fname, e); + invalid_entries.push(&file.fname); + continue; + } } + } else { + // uploading deletion + None }; if let Some(data) = &file_data {