use xdg variables and parallelize some processes
This commit is contained in:
@@ -509,6 +509,9 @@ local_files_present || load_missing_files
|
||||
precompute_views
|
||||
|
||||
# Generate filenames for temporary files
|
||||
# We keep these files in a temporary directory and not in the state directory
|
||||
# because this allows for straight-forward capability to run multiple instances
|
||||
# simultaneously.
|
||||
tmpdir=$(mktemp -d)
|
||||
LOCKFILE="$tmpdir/lock"
|
||||
RESULTS="$tmpdir/results"
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
if [ ! "${CACHE_LOADED:-}" ]; then
|
||||
# Base path for cache
|
||||
CACHEDIR="$HOME/.cache/$APP_NAME"
|
||||
CACHEDIR="${XGD_CACHE_HOME:-"$HOME/.cache"}/$APP_NAME"
|
||||
# Directory names for cache types
|
||||
TYPE_ARTIST="artist"
|
||||
TYPE_RELEASEGROUP="releasegroup"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# the file may be overwritten by specifying the environment variable
|
||||
# `CONFIGFILE`. If a configuration file is specified, then it must also exist.
|
||||
# A configuration file comprises the specification of environment variables
|
||||
# that are` allowed to be set.
|
||||
# that are allowed to be set.
|
||||
#
|
||||
# Currently, the following files hold variables that are configurable:
|
||||
# - `src/sh/filter.sh`: Configuration of filters that can be triggered with
|
||||
@@ -12,7 +12,7 @@
|
||||
# - `src/sh/keys.sh`: Configuration of key bindings to certain actions
|
||||
# - `src/sh/theme.sh`: Configuration of theme
|
||||
# - `src/sh/sort.sh`: List sorting
|
||||
CONFIGFILE_DEFAULT="$HOME/.config/$APP_NAME/config"
|
||||
CONFIGFILE_DEFAULT="${XDG_CONFIG_HOME:-"$HOME/.config"}/$APP_NAME/config"
|
||||
CONFIGFILE="${CONFIGFILE:-"$CONFIGFILE_DEFAULT"}"
|
||||
[ "$CONFIGFILE" != "$CONFIGFILE_DEFAULT" ] && [ ! -f "$CONFIGFILE" ] && err "The configuration file manually specified with the environment variable CONFIGFILE=($CONFIGFILE) does not exist." && exit 1
|
||||
# shellcheck source=/dev/null
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# will also use the methods here, and modifications thereof, to support
|
||||
# MusicBainz collections.
|
||||
if [ ! "${LOCAL_LOADED:-}" ]; then
|
||||
LOCALDATADIR="$HOME/.cache/$APP_NAME/local"
|
||||
LOCALDATADIR="${XDG_DATA_HOME:-"$HOME/.local/share"}/$APP_NAME"
|
||||
LOCALDATA_ARTISTS="$LOCALDATADIR/artists"
|
||||
LOCALDATA_RELEASEGROUPS="$LOCALDATADIR/releasegroups"
|
||||
LOCALDATA_RELEASES="$LOCALDATADIR/releases"
|
||||
@@ -238,7 +238,7 @@ __precompute_lists() {
|
||||
.disambiguation,
|
||||
.["life-span"].begin,
|
||||
.["life-span"].end
|
||||
] | join("\t")' >"$LOCALDATA_ARTISTS_LIST"
|
||||
] | join("\t")' >"$LOCALDATA_ARTISTS_LIST" &
|
||||
cache_get_file_batch "$TYPE_RELEASEGROUP" <"$LOCALDATA_RELEASEGROUPS" | xargs \
|
||||
$JQ '[
|
||||
.id,
|
||||
@@ -247,7 +247,8 @@ __precompute_lists() {
|
||||
."first-release-date",
|
||||
.title,
|
||||
(."artist-credit" | map(([.name, .joinphrase]|join(""))) | join(""))
|
||||
] | join("\t")' >"$LOCALDATA_RELEASEGROUPS_LIST"
|
||||
] | join("\t")' >"$LOCALDATA_RELEASEGROUPS_LIST" &
|
||||
wait
|
||||
}
|
||||
|
||||
# Precompute views
|
||||
@@ -282,19 +283,24 @@ reloaddb() {
|
||||
__batch_load_missing "$TYPE_RELEASE"
|
||||
tmpreleasefiles=$(mktemp)
|
||||
cache_get_file_batch "$TYPE_RELEASE" <"$tmpreleases" >"$tmpreleasefiles"
|
||||
xargs \
|
||||
$JQ '."release-group".id' \
|
||||
<"$tmpreleasefiles" >"$LOCALDATA_RELEASEGROUPS"
|
||||
xargs \
|
||||
$JQ '."release-group"."artist-credit" | map(.artist.id) | join("\n")' \
|
||||
<"$tmpreleasefiles" >"$LOCALDATA_ARTISTS"
|
||||
(
|
||||
xargs \
|
||||
$JQ '."release-group".id' \
|
||||
<"$tmpreleasefiles" >"$LOCALDATA_RELEASEGROUPS"
|
||||
tf1=$(mktemp)
|
||||
sort "$LOCALDATA_RELEASEGROUPS" | uniq >"$tf1"
|
||||
mv "$tf1" "$LOCALDATA_RELEASEGROUPS"
|
||||
) &
|
||||
(
|
||||
xargs \
|
||||
$JQ '."release-group"."artist-credit" | map(.artist.id) | join("\n")' \
|
||||
<"$tmpreleasefiles" >"$LOCALDATA_ARTISTS"
|
||||
tf2=$(mktemp)
|
||||
sort "$LOCALDATA_ARTISTS" | uniq >"$tf2"
|
||||
mv "$tf2" "$LOCALDATA_ARTISTS"
|
||||
) &
|
||||
wait
|
||||
rm -f "$tmpreleases" "$tmpreleasefiles"
|
||||
tf1=$(mktemp)
|
||||
tf2=$(mktemp)
|
||||
sort "$LOCALDATA_RELEASEGROUPS" | uniq >"$tf1"
|
||||
mv "$tf1" "$LOCALDATA_RELEASEGROUPS"
|
||||
sort "$LOCALDATA_ARTISTS" | uniq >"$tf2"
|
||||
mv "$tf2" "$LOCALDATA_ARTISTS"
|
||||
__batch_load_missing "$TYPE_RELEASEGROUP" <"$LOCALDATA_RELEASEGROUPS"
|
||||
__batch_load_missing "$TYPE_ARTIST" <"$LOCALDATA_ARTISTS"
|
||||
__precompute_lists
|
||||
|
||||
@@ -6,7 +6,7 @@ if [ ! "${LOG_LOADED:-}" ]; then
|
||||
ERR="\033[38;5;196m"
|
||||
INFO="\033[38;5;75m"
|
||||
OFF="\033[m"
|
||||
LOGDIR="$HOME/.local/state/$APP_NAME"
|
||||
LOGDIR="${XDG_STATE_HOME:-"$HOME/.local/state"}/$APP_NAME"
|
||||
[ -d "$LOGDIR" ] || mkdir -p "$LOGDIR"
|
||||
LOGFILE="$LOGDIR/log"
|
||||
export ERR INFO OFF LOGFILE
|
||||
|
||||
Reference in New Issue
Block a user