Skip to content

Commit

Permalink
correctly handle NFD content in media DB from older Anki versions
Browse files Browse the repository at this point in the history
  • Loading branch information
dae committed Mar 19, 2020
1 parent 0ecc189 commit 857c0dd
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions rslib/src/media/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 857c0dd

Please sign in to comment.