Rename function

This commit is contained in:
Lukáš Kucharczyk 2022-11-19 00:07:17 +01:00
parent 2dbe0b08c4
commit 1458620bee
Signed by: lukas
SSH Key Fingerprint: SHA256:vMuSwvwAvcT6htVAioMP7rzzwMQNi3roESyhv+nAxeg
1 changed files with 5 additions and 4 deletions

9
tag.sh
View File

@ -203,7 +203,7 @@ add_hash() {
local COLUMN="fid,md5"
local FILENAME="${1:-}"
[ -z "$FILENAME" ] && fail "No file specified."
local FID=$(file_by_filename "$FILENAME")
local FID=$(id_by_filename "$FILENAME")
[[ "$FID" -eq 0 ]] && fail "File \"$FILENAME\" does not exist in database."
sqlite_insert_multi "$TABLE" "$COLUMN" $FID "'$2'"
}
@ -226,7 +226,7 @@ tag_exists_in_db() {
file_exists_in_db() {
# $FILENAME
local RESULT=$(file_by_filename "$1")
local RESULT=$(id_by_filename "$1")
if [[ "$RESULT" -eq 0 ]]; then
return 1
else
@ -234,7 +234,7 @@ file_exists_in_db() {
fi
}
file_by_filename() {
id_by_filename() {
# FILENAME
local FILENAME=$(basename "${1:-}")
local FILEPATH=$(realpath "$(dirname "${1:-}")")
@ -313,7 +313,8 @@ main() {
LABEL="$1"
! tag_exists_in_db "$LABEL" && fail "Tag '$TAG' does not exist in database."
shift
sqlite_query "INSERT INTO tags_ties (fid, tid) VALUES ((SELECT id FROM files WHERE filename = \"$FILENAME\"),(SELECT id FROM tags WHERE label = \"$LABEL\"))"
local FID=$(id_by_filename "$FILENAME")
sqlite_query "INSERT INTO tags_ties (fid, tid) VALUES ($FID,(SELECT id FROM tags WHERE label = \"$LABEL\"))"
COUNTER=$((COUNTER++))
[ -z "${1:-}" ] && break
done