diff --git a/atom b/atom index c52042d..778645b 100755 --- a/atom +++ b/atom @@ -503,15 +503,29 @@ getFiles() { echo 'BEGIN TRANSACTION;' >&3 while read time size filename do - sourcefileid=$( + if ! Select source_files id >/dev/null <<-EOWhere + filename = $filename + mime_type > 0 + last_change >= $time + EOWhere + then + mimetype=$(file -b --mime-type "$sourcepath/$filename") + mimetypeid=$( + InsertIfUnset mime_types <<-EOInsert + mime_text $mimetype + EOInsert + ) InsertOrUpdate source_files \ - last_change ${time%.*} \ + last_change $time \ size $size \ last_seen $scantime \ + mime_type $mimetypeid \ + >/dev/null \ <<-EOWhere filename $filename EOWhere - ) + (( ++new )) + fi case $(( ++count % 4 )) in 0) echo -ne '\r|' ;; 1) echo -ne '\r/' ;; @@ -522,7 +536,7 @@ getFiles() { find "$sourcepath" -type f -printf "%T@ %s %P\n" ) echo 'COMMIT;' >&3 - echo -e "\r$count files found." + echo -e "\r$count files found, ${new:=0} new or changed." } updateMimes() { @@ -536,7 +550,7 @@ updateMimes() { Update mime_type_actions action 0 >/dev/null < <( cat <<-EOWhere destination_id = ${destinationid["$destination"]} - mime_text LIKE ${mime_type//*/%} + mime_text LIKE ${mime_type//\*/%} EOWhere ) done @@ -550,7 +564,7 @@ updateMimes() { Update mime_type_actions action 2 >/dev/null < <( cat <<-EOWhere destination_id = ${destinationid["$destination"]} - mime_text LIKE ${mime_type//*/%} + mime_text LIKE ${mime_type//\*/%} EOWhere ) done