#!/usr/bin/env bash # config structures declare -A \ destinationchannels \ destinationfat32compat \ destinationcopymime \ destinationformat \ destinationfrequency \ destinationid \ destinationloss \ destinationmaxbps \ destinationnormalize \ destinationpath \ destinationquality \ destinationrename \ destinationnoresample \ destinationrenamepath \ destinationskipmime \ || { echo "Check your Bash version. You need >= 4.0" >&2 exit $EBASHVERS } declare -r \ DOCDIR=%DOCDIR% \ LIBDIR=%LIBDIR% \ SHAREDIR=%SHAREDIR% declare -r \ exampleconf=$DOCDIR/example.cfg \ schema=$SHAREDIR/schema.sql \ \ oldIFS="$IFS" LC_ALL=C shopt -s extglob for function in "$LIBDIR"/*/* do source "$function" done if ! [[ -f "${XDG_CONFIG_HOME:-$HOME/.config}/AtOM/atom.cfg" ]] \ && [[ -f "$HOME/.atom/atom.cfg" ]] then echo "Configuration found in legacy location $HOME/.atom/atom.cfg."\ "Migrating configuration and data to XDG standard" xdgMigrate fi cffile="${XDG_CONFIG_HOME:-$HOME/.config}/AtOM/atom.cfg" while getopts 'Dr' opt do case $opt in D) (( debug++ )) ;; r) regen=1 ;; esac done getConfig openDatabase echo 'SELECT id,filename FROM destination_files WHERE filename IS NOT NULL;' >&3 echo 'SELECT "AtOM:NoMoreFiles";' >&3 read -u4 filename until [[ $filename == AtOM:NoMoreFiles ]] do files+=("$filename") read -u4 filename done echo 'BEGIN TRANSACTION;' >&3 echo -n "Checking for missing files... " for filename in "${files[@]}" do id=${filename%%::AtOM:SQL:Sep::*} filename=${filename#*::AtOM:SQL:Sep::} if ! [ -f "$filename" ] then echo -e "\r$filename\033[K" ((regen))&&Update destination_files last_change 0 <<<"id = $id" echo -n "Checking for missing files... " (( missing++ )) fi progressSpin done echo 'COMMIT;' >&3 echo -e "\r${missing:-0} missing files\033[K" closeDatabase