Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
18 changes: 18 additions & 0 deletions test/aur_fallback/detect_aur_caches.t
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
$ source "$TESTDIR/../helper.sh"
> PACMAN_LOG=/dev/null
$ unset XDG_CACHE_HOME
Comment thread
pbrisbin marked this conversation as resolved.
Outdated

Detects yay cache when present

Expand Down Expand Up @@ -28,6 +29,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
Loading