Rename pattern change: fix hang, DB optimisation
This commit is contained in:
parent
0d50cdc61f
commit
c5b50565c5
27
atom
27
atom
@ -720,7 +720,12 @@ do
|
|||||||
' >&3
|
' >&3
|
||||||
|
|
||||||
read -u4 line
|
read -u4 line
|
||||||
if [[ $line != AtOM:NoMoreFiles ]]
|
while [[ $line != AtOM:NoMoreFiles ]]
|
||||||
|
do
|
||||||
|
renamefiles+=("$line")
|
||||||
|
read -u4 line
|
||||||
|
done
|
||||||
|
if (( ${#renamefiles[@]} ))
|
||||||
then
|
then
|
||||||
case "${destinationformat[$destination]}" in
|
case "${destinationformat[$destination]}" in
|
||||||
'mp3') extension=mp3 ;;
|
'mp3') extension=mp3 ;;
|
||||||
@ -728,7 +733,8 @@ do
|
|||||||
'vorbis') extension=ogg ;;
|
'vorbis') extension=ogg ;;
|
||||||
esac
|
esac
|
||||||
echo -n "$destination: rename pattern changed, renaming files... "
|
echo -n "$destination: rename pattern changed, renaming files... "
|
||||||
while [[ $line != AtOM:NoMoreFiles ]]
|
echo 'BEGIN TRANSACTION;' >&3
|
||||||
|
for line in "${renamefiles[@]}"
|
||||||
do
|
do
|
||||||
oldfilename=${line%%::AtOM:SQL:Sep::*}
|
oldfilename=${line%%::AtOM:SQL:Sep::*}
|
||||||
rest=${line#*::AtOM:SQL:Sep::}'::AtOM:SQL:Sep::'
|
rest=${line#*::AtOM:SQL:Sep::}'::AtOM:SQL:Sep::'
|
||||||
@ -761,10 +767,12 @@ do
|
|||||||
getDestDir
|
getDestDir
|
||||||
getDestFile
|
getDestFile
|
||||||
destfilename="$destdir/$destfile.$extension"
|
destfilename="$destdir/$destfile.$extension"
|
||||||
if [[ $oldfilename != $destfilename ]]
|
progressSpin
|
||||||
|
if [[ "$oldfilename" != "$destfilename" ]]
|
||||||
then
|
then
|
||||||
mv "$oldfilename" "$destfilename"
|
mv "$oldfilename" "$destfilename"
|
||||||
progressSpin
|
(( changedcount++ ))
|
||||||
|
commit=1
|
||||||
fi
|
fi
|
||||||
echo "UPDATE destination_files" \
|
echo "UPDATE destination_files" \
|
||||||
"SET filename=\"${destfilename//\"/\"\"}\"," \
|
"SET filename=\"${destfilename//\"/\"\"}\"," \
|
||||||
@ -772,12 +780,17 @@ do
|
|||||||
"\"${destinationrenamepath[$destination]}/${destinationrename[$destination]}:${destinationfat32compat["$destination"]}\"" \
|
"\"${destinationrenamepath[$destination]}/${destinationrename[$destination]}:${destinationfat32compat["$destination"]}\"" \
|
||||||
"WHERE id=$destfileid;" \
|
"WHERE id=$destfileid;" \
|
||||||
>&3
|
>&3
|
||||||
|
if (( commit ))
|
||||||
|
then
|
||||||
|
echo $'COMMIT;\nBEGIN TRANSACTION;' >&3
|
||||||
|
unset commit
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
read -u4 line
|
|
||||||
done
|
done
|
||||||
echo -e $'\r'"$destination: Renamed ${count:-0} files\033[K"
|
echo 'COMMIT;' >&3
|
||||||
|
echo -e $'\r'"$destination: Renamed ${changedcount:-0} files\033[K"
|
||||||
fi
|
fi
|
||||||
unset count
|
unset count changedcount renamefiles
|
||||||
done
|
done
|
||||||
|
|
||||||
copyFiles_action
|
copyFiles_action
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user