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

View File

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