From 617b18ff4926a3a073ab004db3f6ed72f7db7771 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 19 Mar 2020 10:20:42 +1000 Subject: [PATCH] correctly handle NFD content in media DB from older Anki versions --- rslib/src/media/sync.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/rslib/src/media/sync.rs b/rslib/src/media/sync.rs index 5bf7dbcc6..88a879bb0 100644 --- a/rslib/src/media/sync.rs +++ b/rslib/src/media/sync.rs @@ -20,6 +20,7 @@ use std::collections::HashMap; use std::io::{Read, Write}; use std::path::Path; use std::{io, time}; +use unicode_normalization::is_nfc; static SYNC_MAX_FILES: usize = 25; static SYNC_MAX_BYTES: usize = (2.5 * 1024.0 * 1024.0) as usize; @@ -717,6 +718,16 @@ fn zip_files<'a>( break; } + #[cfg(target_vendor = "apple")] + { + if !is_nfc(&file.fname) { + // older Anki versions stored non-normalized filenames in the DB; clean them up + debug!(log, "clean up non-nfc entry"; "fname"=>&file.fname); + 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,