From b838b57e9cff193657941475fa4375e01bcb6f96 Mon Sep 17 00:00:00 2001 From: Xetera Date: Wed, 29 Jan 2025 10:14:24 +0300 Subject: [PATCH] Fix `resolve_globs` crash when at root directory --- crates/oxide/src/scanner/detect_sources.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/crates/oxide/src/scanner/detect_sources.rs b/crates/oxide/src/scanner/detect_sources.rs index a5fcae731dea..6828e8eca7c7 100644 --- a/crates/oxide/src/scanner/detect_sources.rs +++ b/crates/oxide/src/scanner/detect_sources.rs @@ -112,13 +112,16 @@ impl DetectSources { continue; } - // If we are in a directory where the parent is a forced static directory, then this - // will become a forced static directory as well. - if forced_static_directories.contains(&entry.path().parent().unwrap().to_path_buf()) - { - forced_static_directories.push(entry.path().to_path_buf()); - root_directories.insert(entry.path().to_path_buf()); - continue; + // Although normally very unlikely, if running inside a dockerfile + // the current directory might be "/" with no parent + if let Some(parent) = entry.path().parent() { + // If we are in a directory where the parent is a forced static directory, then this + // will become a forced static directory as well. + if forced_static_directories.contains(&parent.to_path_buf()) { + forced_static_directories.push(entry.path().to_path_buf()); + root_directories.insert(entry.path().to_path_buf()); + continue; + } } // If we are in a directory, and the directory is git ignored, then we don't have to