From 7769565a2160951039aa2d4797dad5f4737ffc70 Mon Sep 17 00:00:00 2001 From: jutty Date: Fri, 12 Jul 2024 08:28:21 -0300 Subject: [PATCH] Update cache only when needed --- src/package/validate_input_packages.sh | 25 ++++++++++++++----------- tori | 1 - 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/package/validate_input_packages.sh b/src/package/validate_input_packages.sh index ce183ef..abaec06 100644 --- a/src/package/validate_input_packages.sh +++ b/src/package/validate_input_packages.sh @@ -8,15 +8,18 @@ validate_input_packages() { echo "$package_list" | xargs | sed 's/ /\n/g' | while read -r package; do - if echo "$package" | grep -q "$invalid_characters_pattern"; then - log user "Invalid package: $package (contains invalid characters)" - return 1 - fi - if grep -qw "$package" "$PACKAGE_CACHE"; then - log debug "Found in package cache: $package" - else - log user "Invalid package: $package (not found in package cache)" - return 1 - fi -done + if echo "$package" | grep -q "$invalid_characters_pattern"; then + log user "Invalid package: $package (contains invalid characters)" + return 1 + fi + + update_package_cache + + if grep -qw "$package" "$PACKAGE_CACHE"; then + log debug "Found in package cache: $package" + else + log user "Invalid package: $package (not found in package cache)" + return 1 + fi + done } diff --git a/tori b/tori index 77a5a6b..e7dcd5a 100755 --- a/tori +++ b/tori @@ -34,7 +34,6 @@ main() { # startup checks prepare_directories - update_package_cache # entry point