Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2575,9 +2575,11 @@ deploy_aidevops_agents() {
if [[ "$CLEAN_MODE" == "true" ]]; then
# Build list of directories to preserve: custom, draft, plus plugin namespaces
local -a preserved_dirs=("custom" "draft")
for pns in "${plugin_namespaces[@]}"; do
preserved_dirs+=("$pns")
done
if [[ ${#plugin_namespaces[@]} -gt 0 ]]; then
for pns in "${plugin_namespaces[@]}"; do
preserved_dirs+=("$pns")
done
Comment on lines +2579 to +2581

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This for loop can be made more concise. Since you're inside the if guard, you can safely append the entire plugin_namespaces array to preserved_dirs in one go. This is a more idiomatic way to combine arrays in Bash.

Suggested change
for pns in "${plugin_namespaces[@]}"; do
preserved_dirs+=("$pns")
done
preserved_dirs+=("${plugin_namespaces[@]}")

fi
print_info "Clean mode: removing stale files from $target_dir (preserving ${preserved_dirs[*]})"
local tmp_preserve
tmp_preserve="$(mktemp -d)"
Expand Down Expand Up @@ -2617,18 +2619,22 @@ deploy_aidevops_agents() {
local deploy_ok=false
if command -v rsync &>/dev/null; then
local -a rsync_excludes=("--exclude=loop-state/" "--exclude=custom/" "--exclude=draft/")
for pns in "${plugin_namespaces[@]}"; do
rsync_excludes+=("--exclude=${pns}/")
done
if [[ ${#plugin_namespaces[@]} -gt 0 ]]; then
for pns in "${plugin_namespaces[@]}"; do
rsync_excludes+=("--exclude=${pns}/")
done
fi
if rsync -a "${rsync_excludes[@]}" "$source_dir/" "$target_dir/"; then
deploy_ok=true
fi
else
# Fallback: use tar with exclusions to match rsync behavior
local -a tar_excludes=("--exclude=loop-state" "--exclude=custom" "--exclude=draft")
for pns in "${plugin_namespaces[@]}"; do
tar_excludes+=("--exclude=$pns")
done
if [[ ${#plugin_namespaces[@]} -gt 0 ]]; then
for pns in "${plugin_namespaces[@]}"; do
tar_excludes+=("--exclude=$pns")
done
fi
if (cd "$source_dir" && tar cf - "${tar_excludes[@]}" .) | (cd "$target_dir" && tar xf -); then
deploy_ok=true
fi
Expand Down
Loading