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