! Use new XDG Base specification for state

Switched the history from using the XDG_CACHE_HOME directory by default
to use XDG_STATE_HOME by default.

This makes sense since cache can (and should be prepared to) be wiped at
any moment and the program functionality should not be hindered by this.

Since we need to retain history through such wipes the newly introduced
state directory is the perfect match for keeping the history file in.

This does constitute a small breaking change for existing histories
which need to be moved to the new directory if they made use of the old
cache directory.

Fixes #5.
This commit is contained in:
Marty Oehme 2022-10-12 16:56:15 +02:00
parent 16039fe676
commit 250fb36146
Signed by: Marty
GPG key ID: 73BA40D5AFAF49C9
3 changed files with 11 additions and 6 deletions

View file

@ -39,7 +39,7 @@ database=$BATS_TEST_TMPDIR/xdb-db/bemoji
@test "sets XDG directory for history by default" {
unset BEMOJI_CACHE_LOCATION
export XDG_CACHE_HOME="$BATS_TEST_TMPDIR/xdb-cache"
export XDG_STATE_HOME="$BATS_TEST_TMPDIR/xdb-cache"
run bemoji -v
assert_output --regexp "
history=$BATS_TEST_TMPDIR/xdb-cache/bemoji-history.txt$"
@ -57,7 +57,7 @@ database=$HOME/.local/share/bemoji
unset BEMOJI_CACHE_LOCATION
run bemoji -v
assert_output --regexp "
history=$HOME/.cache/bemoji-history.txt$"
history=$HOME/.local/state/bemoji-history.txt$"
}
@test "BEMOJI_DB_LOCATION sets correct db directory" {