Merge branch 'dev-0.2.5' into dev-0.3
Merging bug fixes from dev-0.2.5
This commit is contained in:
commit
9e4e9327b2
12 changed files with 160 additions and 39 deletions
18
CHANGELOG.md
18
CHANGELOG.md
|
@ -25,3 +25,21 @@
|
|||
* Further improvement to CLI UI
|
||||
* Fixed critical bug with database update, where selection would be defined as "null"
|
||||
* Fixed bug in include command
|
||||
|
||||
### v0.2.3
|
||||
* Fixed bug where dam update would only add one track to the database per image
|
||||
|
||||
### v0.2.4
|
||||
* DAM now downloads image from server if not present
|
||||
* Now properly removes tracks that have been removed in the git directory
|
||||
* A few UI changes
|
||||
* Added options to "fsck" command to allow specific tests to be performed
|
||||
* Fixed bug in nonexistent id test with changing the database
|
||||
* Added --from options to deploy and update to define manually from what git commit hash to update from
|
||||
* Added help menu for fsck, update and deploy commands
|
||||
* Fixed bug in nonexistent id test where non-standard rows would be tests on
|
||||
* Changed --git-dir option to not necessitate "=" sign when defining git directory
|
||||
|
||||
### v0.2.5
|
||||
* Fixed bug with command parser not parsing options correctly
|
||||
* Fixed bug where deploy would fail with errors that didn't exist
|
||||
|
|
7
help/deploy
Normal file
7
help/deploy
Normal file
|
@ -0,0 +1,7 @@
|
|||
Usage: dam deploy [<options>] </path/to/target>
|
||||
|
||||
Deploys tracks to target folder, with applies metadata and cover image
|
||||
|
||||
Options
|
||||
--from <old commit hash>
|
||||
Defines what what commit should dam deploy from. Defaults to when last succesfull deploy occured.
|
13
help/fsck
Normal file
13
help/fsck
Normal file
|
@ -0,0 +1,13 @@
|
|||
Usage: dam [<options>] fsck </path/to/target>
|
||||
|
||||
Performs a series of tests on target's database file. When no options specified, it goes through all tests.
|
||||
|
||||
|
||||
Options
|
||||
--nonexistent-ids
|
||||
Performs test that checks for tracks row that point to non-existent path
|
||||
--deployed-ids
|
||||
Performs test that checks if all flac files present in target is accounted for in database
|
||||
--metadata
|
||||
Performs test that checks if metadata is up to date with git directory
|
||||
|
10
help/general
10
help/general
|
@ -1,13 +1,13 @@
|
|||
Usage: dam [--help] [--info] [<options>] <command> <args>
|
||||
|
||||
Options
|
||||
--git-dir=</path/to/git/dir>
|
||||
--git-dir </path/to/git/dir>
|
||||
Defines path to git directory that contains the music collection. Defaults to current directory when not set.
|
||||
|
||||
Commands
|
||||
update </path/to/target>
|
||||
update [<options>] </path/to/target>
|
||||
Populates database present in target folder with new images.
|
||||
deploy </path/to/target>
|
||||
deploy [<options>] </path/to/target>
|
||||
Deploys tracks to target folder, with applies metadata and cover image
|
||||
exclude </path/to/target> <condition> [<additional condition>]
|
||||
Exclude tracks based on conditions (see dam --help conditions for more information)
|
||||
|
@ -15,5 +15,5 @@ Commands
|
|||
Include tracks based on conditions (see dam --help conditions for more information)
|
||||
du </path/to/target>
|
||||
Prints total projected disk usage of currently selected tracks
|
||||
fsck </path/to/target>
|
||||
Does a series of tests on target's database file
|
||||
fsck [<options>] </path/to/target>
|
||||
Performs a series of tests on target's database file
|
||||
|
|
7
help/update
Normal file
7
help/update
Normal file
|
@ -0,0 +1,7 @@
|
|||
Usage: dam update [<options>] </path/to/target>
|
||||
|
||||
Populates database present in target folder with new images.
|
||||
|
||||
Options
|
||||
--from <old commit hash>
|
||||
Defines what what commit should dam update from. Defaults to when last succesfull update occured.
|
|
@ -15,24 +15,25 @@ chk_nonexistent_ids() {
|
|||
local DB_FILE="${2}"
|
||||
|
||||
local ERR=false
|
||||
local rowList=($(awk 'BEGIN{RS="\n";FS="\t";OFS="="}{print $2,$3,$4}' "${DB_FILE}"))
|
||||
local rowList=($(awk 'BEGIN{RS="\n";FS="\t";OFS="="}{if($1!="LAST_UPDATE" && $1!="LAST_DEPLOY"){print $2,$3,$4}}' "${DB_FILE}"))
|
||||
|
||||
local COUNT=1
|
||||
for row in ${rowList[@]}; do
|
||||
local IMAGEID="$(cut -d"=" -f1 <<< ${row})"
|
||||
local TRACKID="$(cut -d"=" -f2 <<< ${row})"
|
||||
local FILE="$(cut -d"=" -f3 <<< ${row})"
|
||||
local NONEXISTENT=false
|
||||
|
||||
echo "[ ${COUNT} / ${#rowList[@]} ] Checking path of ${TRACKID}"
|
||||
|
||||
if [[ ! -f "${TARGET}/${FILE}" ]] && [[ ${FILE} != "null" ]]; then
|
||||
gawk -i inplace -v imageid=${IMAGEID} trackid=${TRACKID} 'BEGIN{FS="\t";OFS="\t"}{if($2==imageid && $3==trackid){$4="null"}{print $0}}' ${DB_FILE}
|
||||
local $?=1
|
||||
gawk -i inplace -v imageid=${IMAGEID} -v trackid=${TRACKID} 'BEGIN{FS="\t";OFS="\t"}{if($2==imageid && $3==trackid){$4="null"}{print $0}}' ${DB_FILE}
|
||||
local NONEXISTENT=true
|
||||
fi
|
||||
[[ $? -eq 0 ]] || { echo "[>>>>>>] Error reported"; echo "${TRACKID} of ${IMAGEID} points to non-existent file"}; local ERR=true; }
|
||||
[[ "${NONEXISTENT}" == "true" ]] && { echo "[>>>>>>] Error reported"; echo "${TRACKID} of ${IMAGEID} points to non-existent file"}; local ERR=true; }
|
||||
local COUNT=$(( ${COUNT} + 1 ))
|
||||
done
|
||||
[[ "${ERR}" == "true" ]] && { _msg EXEC "Nonexistent files check completed with errors"; _msg WARN; } || { _msg EXEC "Nonexistent files check completed succesfully"; _msg OK; }
|
||||
[[ "${ERR}" == "true" ]] && return 1 || return 0
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -6,13 +6,14 @@
|
|||
# cmd_deploy - Command that deploys IMAGEIDs using deploy_imageid function
|
||||
#
|
||||
# USAGE
|
||||
# cmd_deploy - </path/to/git/dir> </path/to/target>
|
||||
# cmd_deploy - </path/to/git/dir> </path/to/target> [<old git commit>]
|
||||
#
|
||||
# }
|
||||
|
||||
cmd_deploy() {
|
||||
local GIT_DIR="${1}"
|
||||
local TARGET="${2}"; shift 2
|
||||
local TARGET="${2}"
|
||||
local OLD_COMMIT="${3}"
|
||||
local ERR=false
|
||||
local DB_FILE="${TARGET}/${_OPT_DB_FILE}"
|
||||
[[ ! -f "${DB_FILE}" ]] && return 3
|
||||
|
@ -23,8 +24,8 @@ cmd_deploy() {
|
|||
fi
|
||||
|
||||
local NEW_COMMIT=$(git -C "${GIT_DIR}" rev-parse HEAD)
|
||||
local OLD_COMMIT=$(awk 'BEGIN{FS="\t"}{if($1=="LAST_DEPLOY"){print $2}}' ${DB_FILE})
|
||||
local removableidList=($(awk 'BEGIN{FS="\t"}{if(($1=="false" && $1=="null") && $4!="null"){print $2"--"$3}}' "${DB_FILE}"))
|
||||
[[ -z "${OLD_COMMIT}" ]] && local OLD_COMMIT=$(awk 'BEGIN{FS="\t"}{if($1=="LAST_DEPLOY"){print $2}}' ${DB_FILE})
|
||||
local removableidList=($(awk 'BEGIN{FS="\t"}{if(($1=="null" || $1=="false") && $4!="null"){print $2"--"$3}}' "${DB_FILE}"))
|
||||
local deployableidList=($(awk 'BEGIN{FS="\t"}{if($1=="true" && $4=="null"){print $2}}' "${DB_FILE}" | awk '!seen[$0]++'))
|
||||
local changedidList=($(sed 's/\(.*\)\..*/\1/' <<< $(git -C "${GIT_DIR}" diff --name-only ${NEW_COMMIT} ${OLD_COMMIT}) | awk '!seen[$0]++' | grep SHA256))
|
||||
local updateableidList=($(printf "%s\n" ${deployableidList[@]} ${changedidList[@]} | awk '!seen[$0]++'))
|
||||
|
@ -42,7 +43,7 @@ cmd_deploy() {
|
|||
# Cleans target of removable TRACKID
|
||||
local COUNT=1
|
||||
for removableid in ${removableidList[@]}; do
|
||||
echo "[ ${COUNT} / ${#removableidList[@]} ] Removing ${removableid} from ${TARGET}"
|
||||
echo "[ ${COUNT} / ${#removableidList[@]} ] Removing ${removableid}"
|
||||
deploy_rm "${TARGET}" "${DB_FILE}" ${removableid} >${STDERR} 2>&1
|
||||
[[ $? -eq 0 ]] || { echo "[>>>>>>] Error reported"; cat ${STDERR}; local ERR=true; }
|
||||
local COUNT=$(( ${COUNT} + 1 ))
|
||||
|
@ -54,8 +55,16 @@ cmd_deploy() {
|
|||
echo "[ ${COUNT} / ${#updateableidList[@]} ] Deploying ${imageid}"
|
||||
# Processes deployableids (IMAGEIDs that have TRACKIDs that are not present in target, but are selected)
|
||||
if _if_array_contains ${imageid} ${deployableidList[@]}; then
|
||||
local GIT_GET=false
|
||||
if [[ ! -f "${GIT_DIR}/${imageid}.flac" ]]; then
|
||||
git -C "${GIT_DIR}" annex get "${imageid}.flac" >${STDERR} 2>&1
|
||||
local GIT_GET=true
|
||||
[[ $? -ne 0 ]] && { _ansi up 2; echo -en '\033[K'; echo "[ ${COUNT} / ${#updateableidList[@]} ] ${imageid} could not be downloaded from server"; cat ${STDERR}; local ERR=true; continue; }
|
||||
fi
|
||||
deploy_cp "${GIT_DIR}" "${TARGET}" "${DB_FILE}" ${imageid} > ${STDERR} 2>&1
|
||||
[[ $? -ne 0 ]] && { _ansi up 2; echo -en '\033[K'; echo "[ ${COUNT} / ${#updateableidList[@]} ] Copy of ${imageid} completed with errors"; cat ${STDERR}; local ERR=true; continue; }
|
||||
[[ $? -ne 0 ]] && local CP_ERR=true
|
||||
[[ "${GIT_GET}" == "true" ]] && git -C "${GIT_DIR}" annex drop ${imageid}.flac >/dev/null 2>&1
|
||||
[[ "${CP_ERR}" == "true" ]] && { _ansi up 2; echo -en '\033[K'; echo "[ ${COUNT} / ${#updateableidList[@]} ] Copy of ${imageid} completed with errors"; cat ${STDERR}; local ERR=true; continue; }
|
||||
fi
|
||||
|
||||
|
||||
|
|
18
src/cmd_fsck
18
src/cmd_fsck
|
@ -12,13 +12,25 @@
|
|||
|
||||
cmd_fsck() {
|
||||
local GIT_DIR="${1}"
|
||||
local TARGET="${2}"
|
||||
local TARGET="${2}"; shift 2
|
||||
local cmdList=(${@})
|
||||
local DB_FILE="${TARGET}/${_OPT_DB_FILE}"
|
||||
[[ ! -f "${DB_FILE}" ]] && return 3
|
||||
[[ ! -d "${GIT_DIR}/.git" ]] && return 2
|
||||
|
||||
for cmd in ${cmdList[@]}; do
|
||||
case ${cmd} in
|
||||
deployed-ids)
|
||||
chk_deployed_ids "${TARGET}" "${DB_FILE}"
|
||||
chk_nonexistent_ids "${TARGET}" "${DB_FILE}"
|
||||
chk_metadata "${GIT_DIR}" "${TARGET}" "${DB_FILE}"
|
||||
;;
|
||||
|
||||
nonexistent-ids)
|
||||
chk_nonexistent_ids "${TARGET}" "${DB_FILE}"
|
||||
;;
|
||||
|
||||
metadata)
|
||||
chk_metadata "${GIT_DIR}" "${TARGET}" "${DB_FILE}"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
|
|
@ -6,13 +6,14 @@
|
|||
# cmd_update - Updates database of TARGET from git HEAD to last commit hash.
|
||||
#
|
||||
# USAGE
|
||||
# cmd_update </path/to/git/dir> </path/to/target/dir>
|
||||
# cmd_update </path/to/git/dir> </path/to/target/dir> [<old git commit>]
|
||||
#
|
||||
# }
|
||||
|
||||
cmd_update() {
|
||||
local GIT_DIR="${1}"
|
||||
local TARGET="${2}"
|
||||
local OLD_COMMIT="${3}"
|
||||
local DB_FILE="${TARGET}/${_OPT_DB_FILE}"
|
||||
[[ ! -f "${DB_FILE}" ]] && return 3
|
||||
[[ ! -d "${GIT_DIR}/.git" ]] && return 2
|
||||
|
@ -26,7 +27,7 @@ cmd_update() {
|
|||
# Defines what imageids needs updating by determining what files has changed since last
|
||||
# update via git diff --name-only.
|
||||
local NEW_COMMIT=$(git -C "${GIT_DIR}" rev-parse HEAD)
|
||||
local OLD_COMMIT=$(awk 'BEGIN{FS="\t"}{if($1=="LAST_UPDATE"){print $2}}' ${DB_FILE})
|
||||
[[ -z "${OLD_COMMIT}" ]] && local OLD_COMMIT=$(awk 'BEGIN{FS="\t"}{if($1=="LAST_UPDATE"){print $2}}' ${DB_FILE})
|
||||
local imageidList=($(sed 's/\(.*\)\..*/\1/' <<< $(git -C "${GIT_DIR}" diff --name-only ${NEW_COMMIT} ${OLD_COMMIT}) | awk '!seen[$0]++' | grep SHA256))
|
||||
|
||||
local COUNT=1
|
||||
|
|
|
@ -26,6 +26,6 @@ db_update() {
|
|||
if [[ -z $(awk -v imageid="${IMAGEID}" -v trackid="${trackid}" 'BEGIN{FS="\t"}{if($2==imageid && $3==trackid){print $0}}' ${DB_FILE}) ]]; then
|
||||
echo -e "true\t${IMAGEID}\t${trackid}\tnull" >> ${DB_FILE}
|
||||
fi
|
||||
return 0
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
|
|
@ -20,6 +20,6 @@ deploy_rm() {
|
|||
## Removes trackids from TARGET
|
||||
_msg EXEC "Removing ${TRACKID} from ${TARGET}"
|
||||
rm "${TARGET}/$(print_present_path "${DB_FILE}" ${IMAGEID} ${TRACKID})" >${STDERR} 2>&1
|
||||
[[ $? -eq 0 ]] && { _msg OK; gawk -i inplace -v trackid=${TRACKID} -v value=null 'BEGIN{FS="\t";OFS="\t"}{if($3==trackid){$4=value}{print $0}}' ${DB_FILE}; return 1; } || { _msg WARN; return 1; }
|
||||
[[ $? -eq 0 ]] && { _msg OK; gawk -i inplace -v trackid=${TRACKID} -v value=null 'BEGIN{FS="\t";OFS="\t"}{if($3==trackid){$4=value}{print $0}}' ${DB_FILE}; return 0; } || { _msg WARN; return 1; }
|
||||
}
|
||||
|
||||
|
|
77
src/parser
77
src/parser
|
@ -23,14 +23,11 @@ while true; do
|
|||
;;
|
||||
|
||||
|
||||
--git-dir=*)
|
||||
if [ -z "${1#*=}" ]; then
|
||||
help
|
||||
else
|
||||
GIT_DIR="${1#*=}"
|
||||
fi
|
||||
|
||||
--git-dir)
|
||||
shift
|
||||
GIT_DIR="${1}"
|
||||
;;
|
||||
|
||||
*)
|
||||
break
|
||||
;;
|
||||
|
@ -60,20 +57,49 @@ case "${1}" in
|
|||
|
||||
deploy)
|
||||
shift
|
||||
cmd_deploy "${GIT_DIR}" ${@}
|
||||
while [[ -n "${1}" ]]; do
|
||||
case ${1} in
|
||||
--from)
|
||||
shift
|
||||
OLD_COMMIT=${1}
|
||||
shift
|
||||
;;
|
||||
|
||||
*)
|
||||
TARGET="${1}"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
cmd_deploy "${GIT_DIR}" "${TARGET}" "${OLD_COMMIT}"
|
||||
EXIT=$?
|
||||
[[ ${EXIT} -eq 0 ]] && echo "Deployment completed successfully"
|
||||
[[ ${EXIT} -eq 1 ]] && echo "Deployment completed with erros"
|
||||
[[ ${EXIT} -eq 1 ]] && echo "Deployment completed with errors"
|
||||
[[ ${EXIT} -eq 3 ]] && echo "Database file non-existent"
|
||||
[[ ${EXIT} -eq 2 ]] && echo "Git directory not a valid git repository"
|
||||
;;
|
||||
|
||||
update)
|
||||
shift
|
||||
cmd_update "${GIT_DIR}" ${@}
|
||||
while [[ -n "${1}" ]]; do
|
||||
case ${1} in
|
||||
--from)
|
||||
shift
|
||||
OLD_COMMIT=${1}
|
||||
shift
|
||||
;;
|
||||
|
||||
*)
|
||||
TARGET="${1}"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
cmd_update "${GIT_DIR}" "${TARGET}" "${OLD_COMMIT}"
|
||||
EXIT=$?
|
||||
[[ ${EXIT} -eq 0 ]] && echo "Update completed successfully"
|
||||
[[ ${EXIT} -eq 1 ]] && echo "Update completed with erros"
|
||||
[[ ${EXIT} -eq 1 ]] && echo "Update completed with errors"
|
||||
[[ ${EXIT} -eq 3 ]] && echo "Database file non-existent"
|
||||
[[ ${EXIT} -eq 2 ]] && echo "Git directory not a valid git repository"
|
||||
;;
|
||||
|
@ -88,7 +114,34 @@ case "${1}" in
|
|||
|
||||
fsck)
|
||||
shift
|
||||
cmd_fsck "${GIT_DIR}" "${@}"
|
||||
while [[ -n "${1}" ]]; do
|
||||
case ${1} in
|
||||
--nonexistent-ids)
|
||||
cmdList=(${cmdList[@]} nonexistent-ids)
|
||||
shift
|
||||
;;
|
||||
|
||||
--deployed-ids)
|
||||
cmdList=(${cmdList[@]} deployed-ids)
|
||||
shift
|
||||
;;
|
||||
|
||||
--metadata)
|
||||
cmdList=(${cmdList[@]} metadata)
|
||||
shift
|
||||
;;
|
||||
|
||||
*)
|
||||
TARGET="${1}"
|
||||
shift
|
||||
;;
|
||||
|
||||
esac
|
||||
done
|
||||
|
||||
[[ -z ${cmdList[@]} ]] && cmdList=(deployed-ids nonexistent-ids metadata)
|
||||
|
||||
cmd_fsck "${GIT_DIR}" "${TARGET}" ${cmdList[@]}
|
||||
EXIT=$?
|
||||
[[ ${EXIT} -eq 3 ]] && echo "Database file non-existent"
|
||||
[[ ${EXIT} -eq 2 ]] && echo "Git directory not a valid git repository"
|
||||
|
|
Loading…
Reference in a new issue