From 641a006eda4a3b4fb7cf63f61dfd2c9b6ffa50bc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Tue, 16 Nov 2021 13:52:55 +0100 Subject: [PATCH] use grep for fast file search --- db_meta.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/db_meta.sh b/db_meta.sh index e78bcc5..0521ed9 100755 --- a/db_meta.sh +++ b/db_meta.sh @@ -15,7 +15,7 @@ LOCAL_META='local \ META_LENGTH META_WIDTH META_HEIGHT META_TAGS META_COMMENT META_NAME ' -eval "$UNSET_VIDEO" +eval "$UNSET_META" read_meta() { local name="$1" meta_db="$_DATA/.index/meta" @@ -31,10 +31,9 @@ read_meta() { if [ $# -eq 0 ]; then read -r META_LENGTH META_WIDTH META_HEIGHT META_TAGS META_COMMENT META_NAME elif [ "$name" -a -f "$meta_db" -a -r "$meta_db" ]; then - while read -r META_LENGTH META_WIDTH META_HEIGHT META_TAGS META_COMMENT META_NAME; do - [ "${META_NAME%${CR}}" = "$name" ] && break - done <"${meta_db}" - [ "${META_NAME%${CR}}" = "$name" ] || eval "$UNSET_META" + read -r META_LENGTH META_WIDTH META_HEIGHT META_TAGS META_COMMENT META_NAME <<-EOF + $(grep -F " ${name}${CR}" "$meta_db") + EOF fi if [ "$META_NAME" ]; then META_NAME="$(UNSTRING "${META_NAME%${CR}}")" -- 2.39.2