Skip to content

Commit

Permalink
refactor: prevent warn logs for empty directories
Browse files Browse the repository at this point in the history
  • Loading branch information
jmagnuson authored and bpetlert committed Dec 16, 2023
1 parent 6583f59 commit d2282a1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,16 @@ impl ScriptBuilder {
uid: Option<u32>,
gid: Option<u32>,
) -> Result<Vec<ScriptBuilder>> {
let mut scripts: Vec<ScriptBuilder> = Vec::new();

if !path.exists() {
bail!("`{}` does not exist", path.display());
debug!("`{}` does not exist", path.display());
return Ok(scripts);
}

let uid = uid.unwrap_or(0); // Default is UID of root
let gid = gid.unwrap_or(0); // Default is GID of root

let mut scripts: Vec<ScriptBuilder> = Vec::new();

for entry in WalkDir::new(path)
.min_depth(1)
.max_depth(1)
Expand Down Expand Up @@ -171,7 +172,7 @@ impl ScriptBuilder {
}

if scripts.is_empty() {
bail!("No script in `{}`", path.display());
debug!("No script in `{}`", path.display());
}

Ok(scripts)
Expand Down

0 comments on commit d2282a1

Please sign in to comment.