copyFiles_action: Refactor progress info

This commit is contained in:
Vincent Riquer 2025-11-09 05:33:23 +01:00 committed by ScriptFanix
parent c5ad92f587
commit e50bf63f16

View File

@ -1,6 +1,6 @@
#!/bin/bash
copyFiles_action() {
(( cron )) || echo -n "Copying files... "
(( cron )) || echo -n $'Copying files...\033[K'
echo '
SELECT
source_files.filename,
@ -79,15 +79,29 @@ copyFiles_action() {
fi
fi
fi
if cp -al "$sourcepath/$sourcefilename" "$destdir" 2>/dev/null\
|| cp -a "$sourcepath/$sourcefilename" "$destdir"
if cp -a --reflink=always \
"$sourcepath/$sourcefilename" \
"$destdir" \
2>/dev/null \
|| cp -al \
"$sourcepath/$sourcefilename" \
"$destdir" \
2>/dev/null \
|| cp -a \
"$sourcepath/$sourcefilename" \
"$destdir"
then
Update destination_files \
filename "$destdir/${sourcefilename##*/}"\
rename_pattern "${destinationrenamepath[$destination]}/${destinationrename[$destination]}"\
fat32compat ${destinationfat32compat["$destination"]}\
ascii ${destinationascii["$destination"]}\
last_change $lastchange \
filename \
"$destdir/${sourcefilename##*/}"\
rename_pattern \
"${destinationrenamepath[$destination]}/${destinationrename[$destination]}"\
fat32compat \
${destinationfat32compat["$destination"]}\
ascii \
${destinationascii["$destination"]}\
last_change \
$lastchange \
<<-EOWhere
id = $destfileid
EOWhere
@ -98,12 +112,14 @@ copyFiles_action() {
if (( count ))
then
(( cron )) || echo -n $'\r'
if (( count ))
then
echo -n "Copied ${done:-0} of $count" \
"files${postponed+ ($postponed postponed)}."
(( cron )) || echo -en "\033[K"
echo
else
(( cron )) || echo -e "\rNothing to copy.\033[K"
(( cron )) || echo -n $'\r\033[K'
fi
unset count done
}