fpf-cli 1.6.46 → 1.6.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fpf +55 -2
- package/package.json +1 -1
package/fpf
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
set -euo pipefail
|
|
4
4
|
|
|
5
5
|
SCRIPT_NAME="fpf"
|
|
6
|
-
SCRIPT_VERSION="1.6.
|
|
6
|
+
SCRIPT_VERSION="1.6.47"
|
|
7
7
|
TMP_ROOT="${TMPDIR:-/tmp}/fpf"
|
|
8
8
|
SESSION_TMP_ROOT=""
|
|
9
9
|
HELP_FILE=""
|
|
@@ -659,7 +659,24 @@ brew_catalog_state_token() {
|
|
|
659
659
|
printf "state=unknown"
|
|
660
660
|
}
|
|
661
661
|
|
|
662
|
-
|
|
662
|
+
brew_catalog_state_cache_ttl_seconds() {
|
|
663
|
+
local ttl="${FPF_BREW_CATALOG_STATE_TTL:-300}"
|
|
664
|
+
|
|
665
|
+
if ! [[ "${ttl}" =~ ^[0-9]+$ ]]; then
|
|
666
|
+
ttl=300
|
|
667
|
+
fi
|
|
668
|
+
|
|
669
|
+
printf "%s" "${ttl}"
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
brew_catalog_state_cache_scope_hash() {
|
|
673
|
+
local scope_token
|
|
674
|
+
|
|
675
|
+
scope_token="fixtures=${FPF_TEST_FIXTURES:-0};fixture_dir=${FPF_TEST_FIXTURE_DIR:-}"
|
|
676
|
+
cache_cksum "${scope_token}"
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
cache_search_catalog_fingerprint_uncached() {
|
|
663
680
|
local manager="$1"
|
|
664
681
|
local command_path=""
|
|
665
682
|
local state_token="state=unknown"
|
|
@@ -681,6 +698,42 @@ cache_search_catalog_fingerprint() {
|
|
|
681
698
|
printf "%s|cmd=%s|%s" "$(cache_fingerprint "${manager}" "" "search-catalog")" "${command_path}" "${state_token}"
|
|
682
699
|
}
|
|
683
700
|
|
|
701
|
+
cache_search_catalog_fingerprint() {
|
|
702
|
+
local manager="$1"
|
|
703
|
+
local state_cache_key=""
|
|
704
|
+
local state_cache_file=""
|
|
705
|
+
local state_cache_ttl=0
|
|
706
|
+
local state_cache_tmp=""
|
|
707
|
+
local state_cache_scope_hash=""
|
|
708
|
+
|
|
709
|
+
if [[ "${manager}" != "brew" ]]; then
|
|
710
|
+
cache_search_catalog_fingerprint_uncached "${manager}"
|
|
711
|
+
return
|
|
712
|
+
fi
|
|
713
|
+
|
|
714
|
+
initialize_cache_root
|
|
715
|
+
|
|
716
|
+
state_cache_scope_hash="$(brew_catalog_state_cache_scope_hash)"
|
|
717
|
+
state_cache_key="state/search-catalog-fingerprint/${manager}.${state_cache_scope_hash}.txt"
|
|
718
|
+
state_cache_file="$(cache_path_for_key "${state_cache_key}")"
|
|
719
|
+
state_cache_ttl="$(brew_catalog_state_cache_ttl_seconds)"
|
|
720
|
+
|
|
721
|
+
if [[ "${state_cache_ttl}" -gt 0 && -s "${state_cache_file}" ]] && cache_is_fresh_with_ttl "${state_cache_key}" "${state_cache_ttl}"; then
|
|
722
|
+
cat "${state_cache_file}"
|
|
723
|
+
return
|
|
724
|
+
fi
|
|
725
|
+
|
|
726
|
+
state_cache_tmp="$(mktemp "${SESSION_TMP_ROOT}/search-catalog-fingerprint.XXXXXX")"
|
|
727
|
+
cache_search_catalog_fingerprint_uncached "${manager}" >"${state_cache_tmp}" || true
|
|
728
|
+
|
|
729
|
+
if [[ -s "${state_cache_tmp}" ]]; then
|
|
730
|
+
cache_store_key_from_file "${state_cache_key}" "${manager}" "${state_cache_tmp}"
|
|
731
|
+
cat "${state_cache_tmp}"
|
|
732
|
+
fi
|
|
733
|
+
|
|
734
|
+
rm -f "${state_cache_tmp}"
|
|
735
|
+
}
|
|
736
|
+
|
|
684
737
|
cache_search_catalog_key() {
|
|
685
738
|
local manager="$1"
|
|
686
739
|
local fingerprint="$2"
|