Optimize structure/layout of __fish_print_packages

Move XDG_CACHE_HOME logic below package providers that don't use the
cache.
This commit is contained in:
Mahmoud Al-Qudsi 2018-05-17 22:21:19 -05:00
parent 1c4940c04c
commit 4b78c92652

View file

@ -12,12 +12,6 @@ function __fish_print_packages
#Get the word 'Package' in the current language #Get the word 'Package' in the current language
set -l package (_ "Package") set -l package (_ "Package")
# Set up cache directory
if test -z "$XDG_CACHE_HOME"
set XDG_CACHE_HOME $HOME/.cache
end
mkdir -m 700 -p $XDG_CACHE_HOME
if type -q -f apt-cache if type -q -f apt-cache
# Do not generate the cache as apparently sometimes this is slow. # Do not generate the cache as apparently sometimes this is slow.
# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=547550 # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=547550
@ -42,6 +36,14 @@ function __fish_print_packages
return return
end end
### BEGIN CACHED RESULTS ###
# Set up cache directory
if test -z "$XDG_CACHE_HOME"
set XDG_CACHE_HOME $HOME/.cache
end
mkdir -m 700 -p $XDG_CACHE_HOME
# Caches for 5 minutes # Caches for 5 minutes
if type -q -f pacman if type -q -f pacman
set cache_file $XDG_CACHE_HOME/.pac-cache.$USER set cache_file $XDG_CACHE_HOME/.pac-cache.$USER