Skip to content

Commit

Permalink
make if statements more concise
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolemah99 committed Jun 28, 2024
1 parent 768c0fe commit 0989d22
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions cli_meter/cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ num_dirs=$(yq '.directories | length' "$config_path")

# Check if cleanup is enabled
if [ "$enable_cleanup" ]; then
log "Starting cleanup process..."
log "Cleanup enabled, starting cleanup process..."
[[ -z "$num_dirs" || "$num_dirs" -eq 0 ]] && log "No directories to clean."

for ((i = 0; i < num_dirs; i++)); do
Expand All @@ -59,11 +59,7 @@ if [ "$enable_cleanup" ]; then
# Now check and remove empty directories
find "$level0_dir" -depth -type d | while read -r dir; do
if [ -z "$(ls -A "$dir")" ]; then
if rmdir "$dir"; then
log "Removing empty directory: $dir"
else
log "Failed to remove empty directory: $dir"
fi
rmdir "$dir" && log "Removing empty directory: $dir" || log "Failed to remove empty directory: $dir"
fi
done

Expand Down

0 comments on commit 0989d22

Please sign in to comment.