File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed
packages/collector/scripts Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -29,9 +29,21 @@ IFS=$'\n' sorted=($(printf "%s\n" $files | sort))
2929unset IFS
3030
3131total=${# sorted[@]}
32- perGroup=$(( (total + MAX_SPLIT - 1 ) / MAX_SPLIT ))
33- start=$(( (SPLIT - 1 ) * perGroup ))
3432
35- for (( i = start; i < start + perGroup && i < total; i++ )) ; do
33+ # Calculate files per group using floor division
34+ # This ensures more even distribution across all splits
35+ perGroup=$(( total / MAX_SPLIT ))
36+
37+ remainder=$(( total % MAX_SPLIT ))
38+
39+ if [ $SPLIT -le $remainder ]; then
40+ start=$(( (SPLIT - 1 ) * (perGroup + 1 ) ))
41+ count=$(( perGroup + 1 ))
42+ else
43+ start=$(( remainder * (perGroup + 1 ) + (SPLIT - remainder - 1 ) * perGroup ))
44+ count=$perGroup
45+ fi
46+
47+ for (( i = start; i < start + count && i < total; i++ )) ; do
3648 echo " ${sorted[$i]} "
3749done
You can’t perform that action at this time.
0 commit comments