mirror of
https://github.com/markusressel/zfs-inplace-rebalancing
synced 2026-02-05 05:24:07 +00:00
refactor: add regularity to spaces
1) switch all the miscellaneous indentation to 4 spaces 2) remove the space before the parenthesis of function 3) add indentation inside of if 4) remove miscellaneous spaces at the end of lines
This commit is contained in:
parent
4a6fb83c3d
commit
cb89ff94cd
@ -30,14 +30,13 @@ function print_usage() {
|
||||
}
|
||||
|
||||
# print a given text entirely in a given color
|
||||
function color_echo () {
|
||||
function color_echo() {
|
||||
color=$1
|
||||
text=$2
|
||||
echo -e "${color}${text}${Color_Off}"
|
||||
}
|
||||
|
||||
|
||||
function get_rebalance_count () {
|
||||
function get_rebalance_count() {
|
||||
file_path=$1
|
||||
|
||||
line_nr=$(grep -xF -n "${file_path}" "./${rebalance_db_file_name}" | head -n 1 | cut -d: -f1)
|
||||
@ -53,7 +52,7 @@ function get_rebalance_count () {
|
||||
}
|
||||
|
||||
# rebalance a specific file
|
||||
function rebalance () {
|
||||
function rebalance() {
|
||||
file_path=$1
|
||||
|
||||
# check if file has >=2 links in the case of --skip-hardlinks
|
||||
@ -89,7 +88,7 @@ function rebalance () {
|
||||
fi
|
||||
|
||||
current_index="$((current_index + 1))"
|
||||
progress_percent=$(printf '%0.2f' "$((current_index*10000/file_count))e-2")
|
||||
progress_percent=$(printf '%0.2f' "$((current_index * 10000 / file_count))e-2")
|
||||
color_echo "${Cyan}" "Progress -- Files: ${current_index}/${file_count} (${progress_percent}%)"
|
||||
|
||||
if [[ ! -f "${file_path}" ]]; then
|
||||
@ -195,8 +194,8 @@ function rebalance () {
|
||||
line_nr=$(grep -xF -n "${file_path}" "./${rebalance_db_file_name}" | head -n 1 | cut -d: -f1)
|
||||
if [ -z "${line_nr}" ]; then
|
||||
rebalance_count=1
|
||||
echo "${file_path}" >> "./${rebalance_db_file_name}"
|
||||
echo "${rebalance_count}" >> "./${rebalance_db_file_name}"
|
||||
echo "${file_path}" >>"./${rebalance_db_file_name}"
|
||||
echo "${rebalance_count}" >>"./${rebalance_db_file_name}"
|
||||
else
|
||||
rebalance_count_line_nr="$((line_nr + 1))"
|
||||
rebalance_count="$((rebalance_count + 1))"
|
||||
@ -214,13 +213,13 @@ if [[ "$#" -eq 0 ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
while true ; do
|
||||
while true; do
|
||||
case "$1" in
|
||||
-h | --help )
|
||||
-h | --help)
|
||||
print_usage
|
||||
exit 0
|
||||
;;
|
||||
-c | --checksum )
|
||||
-c | --checksum)
|
||||
if [[ "$2" == 1 || "$2" =~ (on|true|yes) ]]; then
|
||||
checksum_flag="true"
|
||||
else
|
||||
@ -228,7 +227,7 @@ while true ; do
|
||||
fi
|
||||
shift 2
|
||||
;;
|
||||
--skip-hardlinks )
|
||||
--skip-hardlinks)
|
||||
if [[ "$2" == 1 || "$2" =~ (on|true|yes) ]]; then
|
||||
skip_hardlinks_flag="true"
|
||||
else
|
||||
@ -236,7 +235,7 @@ while true ; do
|
||||
fi
|
||||
shift 2
|
||||
;;
|
||||
-p | --passes )
|
||||
-p | --passes)
|
||||
passes_flag=$2
|
||||
shift 2
|
||||
;;
|
||||
@ -244,7 +243,7 @@ while true ; do
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done;
|
||||
done
|
||||
|
||||
root_path=$1
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user