From 8daa84f28ffc8b1f955a1a5e83b8cb55f47111e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aljaz=CC=8C=20=22g5pw=22=20Srebrnic=CC=8C?= Date: Wed, 19 Feb 2014 15:28:30 +0100 Subject: [PATCH] A better cache policy for _port This compares modification times of the main PortIndex for all ports and registry.db for installed ports. --- src/_port | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/_port b/src/_port index 3a6eaf2..405872f 100644 --- a/src/_port +++ b/src/_port @@ -225,8 +225,16 @@ _port_select() { } _port_caching_policy() { - local reg_time comp_time - reg_time=$(stat -c '%Z' $port_prefix/var/macports/registry/registry.db) + local reg_time comp_time check_file + case "${1##*/}" in + PORT_INSTALLED_PACKAGES) + check_file=$port_prefix/var/macports/registry/registry.db + ;; + PORT_AVAILABLE_PACKAGES) + check_file=${$(port dir MacPorts)%/*/*}/PortIndex + ;; + esac + reg_time=$(stat -c '%Z' $check_file) comp_time=$(stat -c '%Z' $1) return $(( reg_time < comp_time )) }