From 30e53c51ab98ede0dc98e6f6858a235696793d8b Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 17 Mar 2022 17:49:18 +1000 Subject: [PATCH] Tiny cleanup missing from previous commit Had intended to apply it prior to pushing. --- rslib/src/import_export/package/colpkg/export.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/rslib/src/import_export/package/colpkg/export.rs b/rslib/src/import_export/package/colpkg/export.rs index 63ea482d6..d839508b9 100644 --- a/rslib/src/import_export/package/colpkg/export.rs +++ b/rslib/src/import_export/package/colpkg/export.rs @@ -2,6 +2,7 @@ // License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html use std::{ + borrow::Cow, collections::HashMap, fs::{read_dir, DirEntry, File}, io::{self, Read, Write}, @@ -288,11 +289,9 @@ fn normalized_unicode_file_name(entry: &DirEntry) -> Result { entry.file_name().to_string_lossy() )) })?; - if let Some(filename) = filename_if_normalized(filename) { - Ok(filename.into_owned()) - } else { - Err(AnkiError::MediaCheckRequired) - } + filename_if_normalized(filename) + .map(Cow::into_owned) + .ok_or(AnkiError::MediaCheckRequired) } /// Writes media files while compressing according to the targeted version.