From 2a2d5af36c122b12e0b709e65ae2d7e11cedb7a8 Mon Sep 17 00:00:00 2001 From: rm-dr <96270320+rm-dr@users.noreply.github.com> Date: Mon, 16 Mar 2026 09:54:31 -0700 Subject: [PATCH] Sidecar fixes --- crates/pile-value/src/source/dir.rs | 42 ++++++++++++++++++----------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/crates/pile-value/src/source/dir.rs b/crates/pile-value/src/source/dir.rs index aa7361d..fde1156 100644 --- a/crates/pile-value/src/source/dir.rs +++ b/crates/pile-value/src/source/dir.rs @@ -47,14 +47,20 @@ impl DataSource for Arc { source: Arc::clone(self), mime: mime_guess::from_path(&key).first_or_octet_stream(), path: key.clone(), - sidecar: self.sidecars.then(|| { - Box::new(Item::File { - source: Arc::clone(self), - mime: mime_guess::from_path(key.with_extension("toml")).first_or_octet_stream(), - path: key.with_extension("toml"), - sidecar: None, + sidecar: self + .sidecars + .then(|| { + let sidecar_path = key.with_extension("toml"); + sidecar_path.is_file().then(|| { + Box::new(Item::File { + source: Arc::clone(self), + mime: mime_guess::from_path(&sidecar_path).first_or_octet_stream(), + path: sidecar_path, + sidecar: None, + }) + }) }) - }), + .flatten(), })); } @@ -91,15 +97,21 @@ impl DataSource for Arc { mime: mime_guess::from_path(&path).first_or_octet_stream(), path: path.clone(), - sidecar: source.sidecars.then(|| { - Box::new(Item::File { - source: Arc::clone(&source), - mime: mime_guess::from_path(path.with_extension("toml")) - .first_or_octet_stream(), - path: path.with_extension("toml"), - sidecar: None, + sidecar: source + .sidecars + .then(|| { + let sidecar_path = path.with_extension("toml"); + sidecar_path.is_file().then(|| { + Box::new(Item::File { + source: Arc::clone(&source), + mime: mime_guess::from_path(&sidecar_path) + .first_or_octet_stream(), + path: sidecar_path, + sidecar: None, + }) + }) }) - }), + .flatten(), }, };