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-06-26 17:58:00 +02:00
parent 04e2e85de8
commit 8daa84f28f
+10 -2
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 ))
}