Use own cache policy

This checks modification dates of the repository database and completion cache
and refreshes the latter if it is older than the database.
This commit is contained in:
Aljaž "g5pw" Srebrnič 2013-03-24 22:31:08 +01:00
parent d8a2e94fa0
commit f2cff3dbf3
1 changed files with 13 additions and 0 deletions

View File

@ -70,6 +70,12 @@ _port() {
'*:extra:->extra' \ '*:extra:->extra' \
&& return 0 && return 0
local cache_policy
zstyle -s ":completion:${curcontext}:" cache-policy cache_policy
if [[ -z "$cache_policy" ]]; then
zstyle ":completion:${curcontext}:" cache-policy _port_caching_policy
fi
case "$state" in case "$state" in
extra) extra)
case "$words[2]" in case "$words[2]" in
@ -133,4 +139,11 @@ _port_select() {
fi fi
} }
_port_caching_policy() {
local reg_time comp_time
reg_time=$(stat -c '%Z' $port_prefix/var/macports/registry/registry.db)
comp_time=$(stat -c '%Z' $1)
return $(( reg_time < comp_time ))
}
_port "$@" _port "$@"