A better cache policy for _port

This compares modification times of the main PortIndex for all ports and
registry.db for installed ports.
This commit is contained in:
Aljaž "g5pw" Srebrnič 2014-02-19 15:28:30 +01:00
parent 04e2e85de8
commit 8daa84f28f
1 changed files with 10 additions and 2 deletions

View File

@ -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 ))
}