Implement ascii-only

This commit is contained in:
Vincent Riquer 2013-10-09 17:24:08 +02:00
parent f9143525d0
commit 6f2a29f0d5
4 changed files with 49 additions and 26 deletions

24
atom
View File

@ -301,6 +301,7 @@ then
Renaming to ASCII-only disabled" >&2
unset destinationascii
destinationascii=0
textunidecodeneeded=0
(( sanitywarn++ ))
fi
if (( sanityfail ))
@ -503,6 +504,8 @@ do
done
(( cron )) || echo -n 'Creating tasks... '
(( textunidecodeneeded )) && ascii
echo 'BEGIN TRANSACTION;' >&3
for line in "${decodefiles[@]}"
do
@ -591,6 +594,9 @@ echo 'COMMIT;' >&3
(( cron )) || echo -n $'\r'
echo "Created ${count:-0} tasks for $filecount files ${togo:+($togo left) }(${copies:-0} immediate copies)"
# remove perl unicode to ascii coprocess
(( textunidecodeneeded )) && eval exec "${toascii[1]}>&-"
concurrency=$(( maxload / 2 ))
(( concurrency )) || concurrency=1
active=0
@ -764,7 +770,6 @@ then
exit
fi
#set -x
for destination in "${!destinationpath[@]}"
do
echo '
@ -792,14 +797,18 @@ do
INNER JOIN source_files
ON destination_files.source_file_id
=source_files.id
INNER JOIN mime_actions
ON source_files.mime_type
=mime_actions.mime_type
WHERE destinations.name="'"$destination"'"
AND (destination_files.rename_pattern
!=
"'"${destinationrenamepath[$destination]}/${destinationrename[$destination]}"'"
OR fat32compat != ${destinationfat32compat["$destination"]}
OR ascii != ${destinationascii["$destination"]}
OR fat32compat != '${destinationfat32compat["$destination"]}'
OR ascii != '${destinationascii["$destination"]}'
OR destination_files.rename_pattern is NULL)
AND destination_files.last_change > 0
AND mime_actions.action=1
;
SELECT "AtOM:NoMoreFiles";
@ -819,6 +828,7 @@ do
'vorbis') extension=ogg ;;
esac
(( cron )) || echo -n "$destination: rename pattern changed, renaming files... "
(( textunidecodeneeded )) && ascii
echo 'BEGIN TRANSACTION;' >&3
for line in "${renamefiles[@]}"
do
@ -863,9 +873,9 @@ do
echo "UPDATE destination_files" \
"SET filename=\"${destfilename//\"/\"\"}\"," \
" rename_pattern=" \
"\"${destinationrenamepath[$destination]}/${destinationrename[$destination]}" \
" fat32compat="
"${destinationfat32compat["$destination"]}\"" \
"\"${destinationrenamepath[$destination]}/${destinationrename[$destination]}\","\
" fat32compat=" \
"${destinationfat32compat["$destination"]}," \
" ascii=" \
"${destinationascii["$destination"]}" \
"WHERE id=$destfileid;" \
@ -877,6 +887,8 @@ do
fi
fi
done
# remove perl unicode to ascii coprocess
(( textunidecodeneeded )) && eval exec "${toascii[1]}>&-"
echo 'COMMIT;' >&3
(( cron )) || echo -n $'\r'
echo -n "$destination: Renamed ${changedcount:-0} files"

View File

@ -22,11 +22,11 @@ copyFiles_matching() {
" FROM destination_files" \
" WHERE id=$destfileid" \
" )," \
" rename_pattern" \
"\"${destinationrenamepath[$destination]}/${destinationrename[$destination]}\""\
" fat32compat" \
" ${destinationfat32compat["$destination"]}"\
" ascii ${destinationascii["$destination"]}"\
" rename_pattern=" \
"\"${destinationrenamepath[$destination]}/${destinationrename[$destination]}\","\
" fat32compat=" \
"${destinationfat32compat["$destination"]}," \
" ascii=${destinationascii["$destination"]}" \
"WHERE id=$destfileid;" \
>&3
(( ++copies ))

View File

@ -64,6 +64,11 @@ getDestDir() {
part=${part#*/}
done
fi
if (( ${destinationascii["$destination"]} ))
then
echo "$destdir" >&${toascii[1]}
read -r -u${toascii[0]} destdir
fi
if ! [ -d "$destdir" ]
then
mkdir -p "$destdir"

View File

@ -36,6 +36,7 @@ getDestFile() {
&& [ -n "$disc" ]
)
)
then
destfile="${destinationrename[$destination]//?(\[)%\{album\}?(\])/$album}"
destfile="${destfile//?(\[)%\{albumartist\}?(\])/$albumartist}"
destfile="${destfile//?(\[)%\{artist\}?(\])/$artist}"
@ -49,5 +50,10 @@ getDestFile() {
destfile="${filename##*/}"
destfile="${destfile%.*}"
fi
if (( ${destinationascii["$destination"]} ))
then
echo "$destfile" >&${toascii[1]}
read -r -u${toascii[0]} destfile
fi
destfile=$(sanitizeFile "$destfile")
}