don't leave files with tags.last_change=0.0

add a `tagreader` column to reexamine files later, if the parser has been changed
CAST last_change to TEXT before attempting comparison: FLOATs suck
This commit is contained in:
Vincent Riquer 2013-03-11 13:38:22 +01:00
parent 5154f61f1b
commit 50e690e6f7
2 changed files with 34 additions and 46 deletions

79
atom
View File

@ -704,7 +704,10 @@ gettag() {
| sed -n "/^${1}=/I{s/^${1}=//I;p}" | sed -n "/^${1}=/I{s/^${1}=//I;p}"
} }
getInfosMP3_version='ID3-0.1'
tagreaders+=( "$getInfosMP3_version" )
getInfos::MP3() { getInfos::MP3() {
tagreader="$getInfosMP3_version"
infos=$( infos=$(
soxi -a "$sourcepath/$filename" 2>/dev/null soxi -a "$sourcepath/$filename" 2>/dev/null
) )
@ -715,16 +718,12 @@ getInfos::MP3() {
tracknum=$(gettag tracknumber) tracknum=$(gettag tracknumber)
year=$(gettag year) year=$(gettag year)
getRateChannelSoxi getRateChannelSoxi
[ -n "$album" \
-o -n "$artist" \
-o -n "$genre" \
-o -n "$title" \
-o -n "$tracknum" \
-o -n "$year" ] \
|| return 1
} }
getInfosOgg_version='Ogg-O.1'
tagreaders+=( "$getInfosOgg_version" )
getInfos::Ogg() { getInfos::Ogg() {
tagreader="$getInfosOgg_version"
infos=$( infos=$(
ogginfo "$sourcepath/$filename" \ ogginfo "$sourcepath/$filename" \
| sed 's/\t//' | sed 's/\t//'
@ -747,20 +746,12 @@ getInfos::Ogg() {
infos="${infos//: /=}" infos="${infos//: /=}"
rate=$(gettag rate) rate=$(gettag rate)
channels=$(gettag channels) channels=$(gettag channels)
[ -n "$album" \
-o -n "$albumartist" \
-o -n "$artist" \
-o -n "$composer" \
-o -n "$disc" \
-o -n "$genre" \
-o -n "$performer" \
-o -n "$title" \
-o -n "$tracknum" \
-o -n "$year" ] \
|| return 1
} }
getInfosFLAC_version='FLAC-0.1'
tagreaders+=( "$getInfosFLAC_version" )
getInfos::FLAC() { getInfos::FLAC() {
tagreader="$getInfosFLAC_version"
infos=$( infos=$(
metaflac \ metaflac \
--show-tag=ALBUM \ --show-tag=ALBUM \
@ -800,24 +791,16 @@ getInfos::FLAC() {
--show-channels \ --show-channels \
"$sourcepath/$filename" "$sourcepath/$filename"
) )
[ -n "$album" \
-o -n "$albumartist" \
-o -n "$artist" \
-o -n "$composer" \
-o -n "$disc" \
-o -n "$genre" \
-o -n "$performer" \
-o -n "$title" \
-o -n "$tracknum" \
-o -n "$year" ] \
|| return 1
} }
getInfosAPE_version='APE-0.1'
tagreaders+=( "$getInfosAPE_version" )
getInfos::APE() { getInfos::APE() {
# I was not able to find a decent cli tool to read APE tags. # I was not able to find a decent cli tool to read APE tags.
# This is raw but works for the very few MusePack files I got. # This is raw but works for the very few MusePack files I got.
# #
# Please tell me if you know of any good tool. # Please tell me if you know of any good tool.
tagreader="$getInfosAPE_version"
IFS='=' IFS='='
while read tag value while read tag value
do do
@ -863,17 +846,6 @@ getInfos::APE() {
'^(Album Artist|Artist|Year|Album|Title|Track|Genre|Composer|Performer)=' '^(Album Artist|Artist|Year|Album|Title|Track|Genre|Composer|Performer)='
) )
IFS="$oldIFS" IFS="$oldIFS"
[ -n "$album" \
-o -n "$albumartist" \
-o -n "$artist" \
-o -n "$composer" \
-o -n "$disc" \
-o -n "$genre" \
-o -n "$performer" \
-o -n "$title" \
-o -n "$tracknum" \
-o -n "$year" ] \
|| return 1
} }
tryAPE() { tryAPE() {
@ -882,6 +854,8 @@ tryAPE() {
&& type=APE && type=APE
} }
getTags_version='unknown-0.1'
tagreaders+=( "$getTags_version" )
getTags() { getTags() {
unset type unset type
case "$mimetype" in case "$mimetype" in
@ -913,9 +887,9 @@ getTags() {
esac esac
if [ -n "$type" ] if [ -n "$type" ]
then then
getInfos::$type || return 1 getInfos::$type
else else
return 1 tagreader=$getTags_version
fi fi
} }
@ -1037,6 +1011,10 @@ updateMimes
removeObsoleteFiles removeObsoleteFiles
# get files # get files
for reader in "${tagreaders[@]}"
do
tagreaderclause+="${tagreaderclause:+ AND }NOT tags.tagreader = \"$reader\""
done
echo ' echo '
SELECT COUNT(DISTINCT source_files.filename) SELECT COUNT(DISTINCT source_files.filename)
FROM source_files FROM source_files
@ -1049,8 +1027,12 @@ echo '
INNER JOIN tags INNER JOIN tags
ON source_files.id=tags.source_file ON source_files.id=tags.source_file
WHERE mime_type_actions.id = source_files.mime_type WHERE mime_type_actions.id = source_files.mime_type
AND NOT destination_files.last_change = source_files.last_change AND (
AND NOT tags.last_change = source_files.last_change CAST(tags.last_change AS TEXT)
<>
CAST(source_files.last_change AS TEXT)
OR ('"$tagreaderclause"')
)
AND mime_type_actions.action = 1;' >&3 AND mime_type_actions.action = 1;' >&3
read -u4 filecount read -u4 filecount
echo ' echo '
@ -1069,8 +1051,12 @@ echo '
INNER JOIN tags INNER JOIN tags
ON source_files.id=tags.source_file ON source_files.id=tags.source_file
WHERE mime_type_actions.id = source_files.mime_type WHERE mime_type_actions.id = source_files.mime_type
AND NOT destination_files.last_change = source_files.last_change AND (
AND NOT tags.last_change = source_files.last_change CAST(tags.last_change AS TEXT)
<>
CAST(source_files.last_change AS TEXT)
OR ('"$tagreaderclause"')
)
AND mime_type_actions.action = 1; AND mime_type_actions.action = 1;
SELECT "AtOM:NoMoreFiles";' >&3 SELECT "AtOM:NoMoreFiles";' >&3
@ -1112,6 +1098,7 @@ do
last_change "$lastchange" \ last_change "$lastchange" \
rate "$rate" \ rate "$rate" \
channels "$channels" \ channels "$channels" \
tagreader "$tagreader" \
>/dev/null <<<"source_file = $sourcefileid" >/dev/null <<<"source_file = $sourcefileid"
unset genre \ unset genre \
albumartist \ albumartist \

View File

@ -53,6 +53,7 @@ CREATE TABLE tags (
rate INTEGER, rate INTEGER,
channels INTEGER, channels INTEGER,
last_change FLOAT, last_change FLOAT,
tagreader TEXT,
FOREIGN KEY (source_file) REFERENCES source_files(id) FOREIGN KEY (source_file) REFERENCES source_files(id)
ON DELETE CASCADE ON DELETE CASCADE
); );