From 05c6d3e6626b563ec8d22b9cb905b4343cb03e35 Mon Sep 17 00:00:00 2001 From: Olivier 'reivilibre Date: Sat, 23 Jul 2022 21:55:04 +0100 Subject: [PATCH] Ignore non-UTF-8 file names instead of panicking --- datman/src/tree.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/datman/src/tree.rs b/datman/src/tree.rs index 48645c0..0f6b46d 100644 --- a/datman/src/tree.rs +++ b/datman/src/tree.rs @@ -307,13 +307,11 @@ pub fn scan_with_progress_bar( let entry: DirEntry = entry?; let scanned = scan_with_progress_bar(&entry.path(), progress_bar, one_filesystem)?; if let Some(scanned) = scanned { - children.insert( - entry - .file_name() - .into_string() - .expect("OsString not String"), - scanned, - ); + if let Ok(filename) = entry.file_name().into_string() { + children.insert(filename, scanned); + } else { + warn!("Non-UTF-8 filename; ignoring: {:?}", entry.file_name()) + } } }