Fix file path not being store properly

This commit is contained in:
Lukáš Kucharczyk 2022-11-16 11:01:28 +01:00
parent d162919b3d
commit 1580865b56
Signed by: lukas
SSH Key Fingerprint: SHA256:vMuSwvwAvcT6htVAioMP7rzzwMQNi3roESyhv+nAxeg
1 changed files with 5 additions and 5 deletions

10
tag.sh
View File

@ -150,8 +150,8 @@ add_path() {
COLUMN="filename,path"
FILES=()
for FILE in "$@"; do
FILENAME=$(basename "$FILE")
FILEPATH=$(dirname "$FILE")
local FILENAME=$(basename "$FILE")
local FILEPATH=$(realpath $(dirname "$FILE"))
file_exists_in_db "$FILE" && fail "File '$FILE' already exists in database."
FILES+=("'$FILENAME'")
FILES+=("'$FILEPATH'")
@ -187,9 +187,9 @@ tag_exists_in_db() {
file_exists_in_db() {
# $FILENAME
FILENAME=$(basename "${1:-}")
FILEPATH=$(dirname "${1:-}")
RESULT=$(sqlite_query "SELECT id FROM files WHERE filename = '$FILENAME' AND path = '$FILEPATH'")
local FILENAME=$(basename "${1:-}")
local FILEPATH=$(dirname "${1:-}")
local RESULT=$(sqlite_query "SELECT id FROM files WHERE filename = '$FILENAME' AND path = '$FILEPATH'")
if [[ -z "$RESULT" ]]; then
return 1
else