Skip to content

Commit

Permalink
chore: ignore .DS_Store (fixes #20)
Browse files Browse the repository at this point in the history
  • Loading branch information
koehlma committed Feb 16, 2024
1 parent c98025e commit dd65515
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion crates/rugpi-bakery/src/project/library.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{collections::HashMap, fs, ops::Deref, str::FromStr, sync::Arc};
use std::{collections::HashMap, fs, ops::Deref, path::Path, str::FromStr, sync::Arc};

use rugpi_common::Anyhow;

Expand Down Expand Up @@ -38,6 +38,10 @@ impl Library {
if recipes_dir.is_dir() {
for entry in fs::read_dir(repository.source.dir.join("recipes"))? {
let entry = entry?;
let path = entry.path();
if !path.is_dir() || should_ignore_path(&path) {
continue;
}
let recipe = loader.load(&entry.path())?;
let recipe_idx = recipes.push(Arc::new(recipe));
table.insert(recipes[recipe_idx].name.deref().to_owned(), recipe_idx);
Expand All @@ -61,6 +65,9 @@ impl Library {
for entry in fs::read_dir(layers_dir)? {
let entry = entry?;
let path = entry.path();
if !path.is_file() || should_ignore_path(&path) {
continue;
}
let mut name = path.file_stem().unwrap().to_string_lossy().into_owned();
let mut arch = None;
if let Some((layer_name, arch_str)) = name.split_once('.') {
Expand Down Expand Up @@ -138,3 +145,11 @@ new_idx_type! {
/// Uniquely identifies a layer in [`Library`].
pub LayerIdx
}

/// Indicates whether the given path should be ignored when scanning for recipes and layers.
fn should_ignore_path(path: &Path) -> bool {
let Some(file_name) = path.file_name() else {
return false;
};
matches!(&*file_name.to_string_lossy(), ".DS_Store")
}

0 comments on commit dd65515

Please sign in to comment.