Merge branch 'smarter-tag-change'
This commit is contained in:
commit
0f4ea73ae6
@ -4,32 +4,25 @@ updateTags() {
|
|||||||
do
|
do
|
||||||
tagreaderclause+="${tagreaderclause:+ AND }NOT tags.tagreader = \"$reader\""
|
tagreaderclause+="${tagreaderclause:+ AND }NOT tags.tagreader = \"$reader\""
|
||||||
done
|
done
|
||||||
echo '
|
|
||||||
SELECT COUNT(DISTINCT source_files.filename)
|
|
||||||
FROM source_files
|
|
||||||
INNER JOIN destination_files
|
|
||||||
ON destination_files.source_file_id=source_files.id
|
|
||||||
INNER JOIN destinations
|
|
||||||
ON destination_files.destination_id=destinations.id
|
|
||||||
INNER JOIN mime_type_actions
|
|
||||||
ON destinations.id=mime_type_actions.destination_id
|
|
||||||
INNER JOIN tags
|
|
||||||
ON source_files.id=tags.source_file
|
|
||||||
WHERE mime_type_actions.id = source_files.mime_type
|
|
||||||
AND (
|
|
||||||
CAST(tags.last_change AS TEXT)
|
|
||||||
<>
|
|
||||||
CAST(source_files.last_change AS TEXT)
|
|
||||||
OR ('"$tagreaderclause"')
|
|
||||||
)
|
|
||||||
AND mime_type_actions.action = 1;' >&3
|
|
||||||
read -u4 filecount
|
|
||||||
echo '
|
echo '
|
||||||
SELECT DISTINCT
|
SELECT DISTINCT
|
||||||
source_files.id,
|
source_files.id,
|
||||||
source_files.last_change,
|
source_files.last_change,
|
||||||
mime_type_actions.mime_text,
|
mime_type_actions.mime_text,
|
||||||
source_files.filename
|
source_files.filename,
|
||||||
|
tags.album,
|
||||||
|
tags.albumartist,
|
||||||
|
tags.artist,
|
||||||
|
tags.composer,
|
||||||
|
tags.disc,
|
||||||
|
tags.genre,
|
||||||
|
tags.performer,
|
||||||
|
tags.title,
|
||||||
|
tags.track,
|
||||||
|
tags.year,
|
||||||
|
tags.rate,
|
||||||
|
tags.channels,
|
||||||
|
tags.bitrate
|
||||||
FROM source_files
|
FROM source_files
|
||||||
INNER JOIN destination_files
|
INNER JOIN destination_files
|
||||||
ON destination_files.source_file_id=source_files.id
|
ON destination_files.source_file_id=source_files.id
|
||||||
@ -53,6 +46,7 @@ updateTags() {
|
|||||||
while ! [[ $line = AtOM:NoMoreFiles ]]
|
while ! [[ $line = AtOM:NoMoreFiles ]]
|
||||||
do
|
do
|
||||||
tagfiles+=("$line")
|
tagfiles+=("$line")
|
||||||
|
(( filecount++ ))
|
||||||
read -u4 line
|
read -u4 line
|
||||||
done
|
done
|
||||||
echo 'BEGIN TRANSACTION;' >&3
|
echo 'BEGIN TRANSACTION;' >&3
|
||||||
@ -63,7 +57,34 @@ updateTags() {
|
|||||||
lastchange=${rest%%::AtOM:SQL:Sep::*}
|
lastchange=${rest%%::AtOM:SQL:Sep::*}
|
||||||
rest=${rest#*::AtOM:SQL:Sep::}
|
rest=${rest#*::AtOM:SQL:Sep::}
|
||||||
mimetype=${rest%%::AtOM:SQL:Sep::*}
|
mimetype=${rest%%::AtOM:SQL:Sep::*}
|
||||||
filename=${rest#*::AtOM:SQL:Sep::}
|
rest=${rest#*::AtOM:SQL:Sep::}
|
||||||
|
filename=${rest%%::AtOM:SQL:Sep::*}
|
||||||
|
rest=${rest#*::AtOM:SQL:Sep::}
|
||||||
|
oldalbum=${rest%%::AtOM:SQL:Sep::*}
|
||||||
|
rest=${rest#*::AtOM:SQL:Sep::}
|
||||||
|
oldalbumartist=${rest%%::AtOM:SQL:Sep::*}
|
||||||
|
rest=${rest#*::AtOM:SQL:Sep::}
|
||||||
|
oldartist=${rest%%::AtOM:SQL:Sep::*}
|
||||||
|
rest=${rest#*::AtOM:SQL:Sep::}
|
||||||
|
oldcomposer=${rest%%::AtOM:SQL:Sep::*}
|
||||||
|
rest=${rest#*::AtOM:SQL:Sep::}
|
||||||
|
olddisc=${rest%%::AtOM:SQL:Sep::*}
|
||||||
|
rest=${rest#*::AtOM:SQL:Sep::}
|
||||||
|
oldgenre=${rest%%::AtOM:SQL:Sep::*}
|
||||||
|
rest=${rest#*::AtOM:SQL:Sep::}
|
||||||
|
oldperformer=${rest%%::AtOM:SQL:Sep::*}
|
||||||
|
rest=${rest#*::AtOM:SQL:Sep::}
|
||||||
|
oldtitle=${rest%%::AtOM:SQL:Sep::*}
|
||||||
|
rest=${rest#*::AtOM:SQL:Sep::}
|
||||||
|
oldtrack=${rest%%::AtOM:SQL:Sep::*}
|
||||||
|
rest=${rest#*::AtOM:SQL:Sep::}
|
||||||
|
oldyear=${rest%%::AtOM:SQL:Sep::*}
|
||||||
|
rest=${rest#*::AtOM:SQL:Sep::}
|
||||||
|
oldrate=${rest%%::AtOM:SQL:Sep::*}
|
||||||
|
rest=${rest#*::AtOM:SQL:Sep::}
|
||||||
|
oldchannels=${rest%%::AtOM:SQL:Sep::*}
|
||||||
|
rest=${rest#*::AtOM:SQL:Sep::}
|
||||||
|
oldbitrate=${rest%%::AtOM:SQL:Sep::*}
|
||||||
echo -en "\rTags: $((++count*100/filecount))%"
|
echo -en "\rTags: $((++count*100/filecount))%"
|
||||||
if (( count % 1000 == 0 ))
|
if (( count % 1000 == 0 ))
|
||||||
then
|
then
|
||||||
@ -73,21 +94,34 @@ updateTags() {
|
|||||||
fi
|
fi
|
||||||
if getTags
|
if getTags
|
||||||
then
|
then
|
||||||
|
[[ $oldalbum != "$album" ]]&& ual=1
|
||||||
|
[[ $oldalbumartist != "$albumartist" ]]&&uaa=1
|
||||||
|
[[ $oldartist != "$artist" ]]&& uar=1
|
||||||
|
[[ $oldcomposer != "$composer" ]]&& uco=1
|
||||||
|
[[ $olddisc != "$disc" ]]&& udi=1
|
||||||
|
[[ $oldgenre != "$genre" ]]&& uge=1
|
||||||
|
[[ $oldperformer != "$performer" ]]&& upe=1
|
||||||
|
[[ $oldtitle != "$title" ]]&& uti=1
|
||||||
|
[[ $oldtrack != "$tracknum" ]]&& utr=1
|
||||||
|
[[ $oldyear != "$year" ]]&& uye=1
|
||||||
|
[[ $oldrate != "$rate" ]]&& ura=1
|
||||||
|
[[ $oldchannels != "$channels" ]]&& uch=1
|
||||||
|
[[ $oldbitrate != "$bitrate" ]]&& ubi=1
|
||||||
Update tags \
|
Update tags \
|
||||||
album "${album:-NULL}" \
|
${ual:+album "${album:-NULL}"} \
|
||||||
albumartist "${albumartist:-NULL}" \
|
${uaa:+albumartist "${albumartist:-NULL}"} \
|
||||||
artist "${artist:-NULL}" \
|
${uar:+artist "${artist:-NULL}"} \
|
||||||
composer "${composer:-NULL}" \
|
${uco:+composer "${composer:-NULL}"} \
|
||||||
disc "${disc:-NULL}" \
|
${udi:+disc "${disc:-NULL}"} \
|
||||||
genre "${genre:-NULL}" \
|
${uge:+genre "${genre:-NULL}"} \
|
||||||
performer "${performer:-NULL}" \
|
${upe:+performer "${performer:-NULL}"} \
|
||||||
title "${title:-NULL}" \
|
${uti:+title "${title:-NULL}"} \
|
||||||
track "${tracknum:-NULL}" \
|
${utr:+track "${tracknum:-NULL}"} \
|
||||||
year "${year:-NULL}" \
|
${uye:+year "${year:-NULL}"} \
|
||||||
last_change "$lastchange" \
|
last_change "$lastchange" \
|
||||||
rate "${rate:-NULL}" \
|
${ura:+rate "${rate:-NULL}"} \
|
||||||
channels "${channels:-NULL}" \
|
${uch:+channels "${channels:-NULL}"} \
|
||||||
bitrate "${bitrate:-NULL}" \
|
${ubi:+bitrate "${bitrate:-NULL}"} \
|
||||||
tagreader "$tagreader" \
|
tagreader "$tagreader" \
|
||||||
>/dev/null <<<"source_file = $sourcefileid"
|
>/dev/null <<<"source_file = $sourcefileid"
|
||||||
unset genre \
|
unset genre \
|
||||||
@ -102,7 +136,20 @@ updateTags() {
|
|||||||
performer \
|
performer \
|
||||||
rate \
|
rate \
|
||||||
bitrate \
|
bitrate \
|
||||||
channels
|
channels \
|
||||||
|
ual \
|
||||||
|
uaa \
|
||||||
|
uar \
|
||||||
|
uco \
|
||||||
|
udi \
|
||||||
|
uge \
|
||||||
|
upe \
|
||||||
|
uti \
|
||||||
|
utr \
|
||||||
|
uye \
|
||||||
|
ura \
|
||||||
|
uch \
|
||||||
|
ubi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
echo 'COMMIT;' >&3
|
echo 'COMMIT;' >&3
|
||||||
|
|||||||
@ -110,8 +110,23 @@ CREATE TRIGGER IF NOT EXISTS create_tags AFTER INSERT ON source_files
|
|||||||
BEGIN
|
BEGIN
|
||||||
INSERT INTO tags (source_file,last_change) VALUES (new.id,0);
|
INSERT INTO tags (source_file,last_change) VALUES (new.id,0);
|
||||||
END;
|
END;
|
||||||
CREATE TRIGGER IF NOT EXISTS force_destination_update_on_tag_update
|
DROP TRIGGER IF EXISTS force_destination_update_on_tag_update;
|
||||||
AFTER UPDATE ON tags
|
CREATE TRIGGER force_destination_update_on_tag_update
|
||||||
|
AFTER UPDATE OF
|
||||||
|
genre,
|
||||||
|
albumartist,
|
||||||
|
year,
|
||||||
|
album,
|
||||||
|
disc,
|
||||||
|
artist,
|
||||||
|
track,
|
||||||
|
title,
|
||||||
|
composer,
|
||||||
|
performer,
|
||||||
|
rate,
|
||||||
|
channels,
|
||||||
|
bitrate
|
||||||
|
ON tags
|
||||||
BEGIN
|
BEGIN
|
||||||
UPDATE destination_files SET last_change=0
|
UPDATE destination_files SET last_change=0
|
||||||
WHERE source_file_id=old.source_file;
|
WHERE source_file_id=old.source_file;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user