35 lines
1.2 KiB
Bash
35 lines
1.2 KiB
Bash
#!/bin/bash
|
|
|
|
# doc cmd_exclude {
|
|
#
|
|
# DESCRIPTION
|
|
# cmd_exclude - Excludes track that matches CONDITION in DB_FILE
|
|
#
|
|
# USAGE
|
|
# cmd_exclude </path/to/dir/dir> </path/to/target> </path/to/db_file> <condition_1> <condition_2> <...>
|
|
#
|
|
# CONDITIONS
|
|
# CONDITIONS are defined using the following format:
|
|
# <metadata field>=<value>
|
|
# The metadata field can be anything that can be injected as metadata in a Vorbis or id3tag.
|
|
#
|
|
# }
|
|
|
|
cmd_exclude() {
|
|
local GIT_DIR="${1}"
|
|
local TARGET="${2}"
|
|
local DB_FILE="${TARGET}/${_OPT_DB_FILE}"; shift 2
|
|
local conditionList=("${@}")
|
|
[[ ! -f "${DB_FILE}" ]] && return 3
|
|
[[ ! -d "${GIT_DIR}/.git" ]] && return 2
|
|
|
|
for condition in ${conditionList[@]}; do
|
|
_msg EXEC "Excluding all tracks that match the following condition: ${condition}"
|
|
local MATCHES=$(db_set ${GIT_DIR} ${DB_FILE} false "${condition}" 2>${STDERR} | wc -l )
|
|
_msg ECHO "${MATCHES} matches"
|
|
[[ $? -ne 0 ]] && { _msg WARN 2; } || { _msg OK 2; }
|
|
done
|
|
local imageidList=($(awk 'BEGIN{FS="\t"}{if($1=="true"){print $2}}' ${DB_FILE} | awk '!seen[$0]++'))
|
|
local DU="$(print_imageid_du ${GIT_DIR} ${imageidList[@]})"
|
|
_msg ECHO "Current estimated disk usage: ${DU} bytes"
|
|
}
|