Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/downgrade
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ get_real_user_home() {
}

detect_aur_caches() {
local home
home=$(get_real_user_home)
local cache_home
cache_home="${XDG_CACHE_HOME:-$(get_real_user_home)/.cache}"

[[ -z "$home" ]] && return 0
[[ -z "$cache_home" ]] && return 0

[[ -d "$home/.cache/yay" ]] && printf '%s\n' "$home/.cache/yay"
[[ -d "$home/.cache/paru/clone" ]] && printf '%s\n' "$home/.cache/paru/clone"
[[ -d "$cache_home/yay" ]] && printf '%s\n' "$cache_home/yay"
[[ -d "$cache_home/paru/clone" ]] && printf '%s\n' "$cache_home/paru/clone"
}

currently_installed() {
Expand Down
17 changes: 17 additions & 0 deletions test/aur_fallback/detect_aur_caches.t
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,23 @@ Detects both when both present
/tmp/*/yay (glob)
/tmp/*/paru/clone (glob)

Detects both when both present, with xdg taking precedence

$ fake_home=$(mktemp -d --suffix @home)
$ fake_xdg=$(mktemp -d --suffix @xdg)
> XDG_CACHE_HOME="$fake_xdg"
> mkdir -p "$fake_xdg/yay"
> mkdir -p "$fake_xdg/paru/clone"
> mkdir -p "$fake_home/.cache/yay"
> mkdir -p "$fake_home/.cache/paru/clone"
> get_real_user_home() { echo "$fake_home"; }
> detect_aur_caches
Comment thread
pbrisbin marked this conversation as resolved.
/tmp/*@xdg/yay (glob)
/tmp/*@xdg/paru/clone (glob)
Unset so doesnt get used by other tests
$ unset XDG_CACHE_HOME

Comment thread
pbrisbin marked this conversation as resolved.
Outdated

Returns nothing when neither present

$ fake_home=$(mktemp -d)
Expand Down
1 change: 1 addition & 0 deletions test/helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export DOWNGRADE_FROM_ALA=0
export DOWNGRADE_FROM_CACHE=0
export DOWNGRADE_CONF="$SRCDIR/test/conf/downgrade_test.conf"
export PACIGNORE_DEFAULT_CHECK=1
export XDG_CACHE_HOME=""

# Stub functions that won't work (on CI) or need different behavior.
pacsort() { cat; }
Expand Down