Skip to content

Commit 6d04426

Browse files
author
kai (moka)
committed
store downloaded archives in DASHT_CACHE_DIR ...
instead of using DASHT_DOCSETS_DIR. This improves interoperability with dash-docs.el (see https://github.com/dash-docs-el/dash-docs) which otherwise tries to list contents of archives stored in the DOCSETS directory when creating a list of installed docsets.
1 parent 882c7f2 commit 6d04426

6 files changed

+35
-11
lines changed

bin/dasht-docsets-install

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@
4040
# or, if `XDG_DATA_HOME` is undefined, `$HOME/.local/share/dasht/docsets/`.
4141
#
4242
# `DASHT_CACHE_DIR`
43-
# Defines the filesystem location where download links are cached.
44-
# If undefined, its value is assumed to be `$XDG_CACHE_HOME/dasht/`
45-
# or, if `XDG_CACHE_HOME` is also undefined, `$HOME/.cache/dasht/`.
43+
# Defines the filesystem location where download links and downloaded
44+
# archives are cached. If undefined, its value is assumed to be
45+
# `$XDG_CACHE_HOME/dasht/` or, if `XDG_CACHE_HOME` is also undefined,
46+
# `$HOME/.cache/dasht/`.
4647
#
4748
# ## SEE ALSO
4849
#
@@ -89,9 +90,9 @@ for docset; do
8990
echo "Install $docset docset [y/N]" | xargs -p | grep -q . || continue
9091

9192
basename="$docset".tgz
92-
tgz="$DASHT_DOCSETS_DIR/$basename"
93+
tgz="$DASHT_CACHE_DIR/$basename"
9394
url="https://kapeli.com/feeds/$basename"
9495

95-
wget -P "$DASHT_DOCSETS_DIR" -N -c "$url"
96+
wget -P "$DASHT_CACHE_DIR" -N -c "$url"
9697
gzip -t "$tgz" && dasht-docsets-extract "$tgz"
9798
done

bin/dasht-docsets-remove

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@
3939
# If undefined, its value is assumed to be `$XDG_DATA_HOME/dasht/docsets/`
4040
# or, if `XDG_DATA_HOME` is undefined, `$HOME/.local/share/dasht/docsets/`.
4141
#
42+
# `DASHT_CACHE_DIR`
43+
# Defines the filesystem location where download links and downloaded
44+
# archives are cached. If undefined, its value is assumed to be
45+
# `$XDG_CACHE_HOME/dasht/` or, if `XDG_CACHE_HOME` is also undefined,
46+
# `$HOME/.cache/dasht/`.
47+
#
4248
# ## SEE ALSO
4349
#
4450
# dasht-docsets-install(1), dasht-docsets-update(1), dasht-docsets(1), [Dash]
@@ -51,6 +57,7 @@
5157
# Distributed under the terms of the ISC license (refer to README file).
5258

5359
: ${DASHT_DOCSETS_DIR:=${XDG_DATA_HOME:-$HOME/.local/share}/dasht/docsets}
60+
: ${DASHT_CACHE_DIR:=${XDG_CACHE_HOME:-$HOME/.cache}/dasht}
5461

5562
test "$1" = '-f' -o "$1" = '--force' && force=1 && shift || unset force
5663

@@ -62,7 +69,6 @@ for docset; do
6269
test -n "$force" || # don't ask for confirmation when it's being forced
6370
echo "Remove $docset docset [y/N]" | xargs -p | grep -q . || continue
6471

65-
rootname="$DASHT_DOCSETS_DIR/$docset"
66-
rm -v -f -r "$rootname".docset \
67-
"$rootname".tgz
72+
rm -v -f -r "$DASHT_DOCSETS_DIR/$docset".docset \
73+
"$DASHT_CACHE_DIR/$docset".tgz
6874
done

bin/dasht-docsets-update

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@
3333
# If undefined, its value is assumed to be `$XDG_DATA_HOME/dasht/docsets/`
3434
# or, if `XDG_DATA_HOME` is undefined, `$HOME/.local/share/dasht/docsets/`.
3535
#
36+
# `DASHT_CACHE_DIR`
37+
# Defines the filesystem location where download links and downloaded
38+
# archives are cached. If undefined, its value is assumed to be
39+
# `$XDG_CACHE_HOME/dasht/` or, if `XDG_CACHE_HOME` is also undefined,
40+
# `$HOME/.cache/dasht/`.
41+
#
3642
# ## SEE ALSO
3743
#
3844
# dasht-docsets-extract(1), dasht-docsets-install(1), dasht-docsets-remove(1),
@@ -46,15 +52,16 @@
4652
# Distributed under the terms of the ISC license (refer to README file).
4753

4854
: ${DASHT_DOCSETS_DIR:=${XDG_DATA_HOME:-$HOME/.local/share}/dasht/docsets}
55+
: ${DASHT_CACHE_DIR:=${XDG_CACHE_HOME:-$HOME/.cache}/dasht}
4956

5057
dasht-docsets "$@" | while read -r docset; do
51-
ls "$DASHT_DOCSETS_DIR/$docset"*.tgz
58+
ls "$DASHT_CACHE_DIR/$docset"*.tgz
5259
done | sort -u | while read -r tgz; do
5360
last_modified_at="$tgz".last_modified_at
5461
url="https://kapeli.com/feeds/$(basename "$tgz")"
5562

5663
touch -r "$tgz" "$last_modified_at"
57-
wget -P "$DASHT_DOCSETS_DIR" -N "$url"
64+
wget -P "$DASHT_CACHE_DIR" -N "$url"
5865
test "$tgz" -nt "$last_modified_at" && dasht-docsets-extract "$tgz"
5966
rm "$last_modified_at"
6067
done

man/man1/dasht-docsets-install.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ If undefined, its value is assumed to be \fB\fC$XDG_DATA_HOME/dasht/docsets/\fR
3434
or, if \fB\fCXDG_DATA_HOME\fR is undefined, \fB\fC$HOME/.local/share/dasht/docsets/\fR\&.
3535
.TP
3636
\fB\fCDASHT_CACHE_DIR\fR
37-
Defines the filesystem location where download links are cached.
37+
Defines the filesystem location where download links and downloaded archives are cached.
3838
If undefined, its value is assumed to be \fB\fC$XDG_CACHE_HOME/dasht/\fR
3939
or, if \fB\fCXDG_CACHE_HOME\fR is also undefined, \fB\fC$HOME/.cache/dasht/\fR\&.
4040
.SH SEE ALSO

man/man1/dasht-docsets-remove.1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ Forces the operation by overriding the interactive confirmation prompt.
3232
Defines the filesystem location where your Dash \[la]https://kapeli.com/dash\[ra] docsets are installed.
3333
If undefined, its value is assumed to be \fB\fC$XDG_DATA_HOME/dasht/docsets/\fR
3434
or, if \fB\fCXDG_DATA_HOME\fR is undefined, \fB\fC$HOME/.local/share/dasht/docsets/\fR\&.
35+
.TP
36+
\fB\fCDASHT_CACHE_DIR\fR
37+
Defines the filesystem location where download links and downloaded archives are cached.
38+
If undefined, its value is assumed to be \fB\fC$XDG_CACHE_HOME/dasht/\fR
39+
or, if \fB\fCXDG_CACHE_HOME\fR is also undefined, \fB\fC$HOME/.cache/dasht/\fR\&.
3540
.SH SEE ALSO
3641
.PP
3742
.BR dasht-docsets-install (1),

man/man1/dasht-docsets-update.1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ patterns. If no \fINAME\fPs are given, all available docsets are matched.
2727
Defines the filesystem location where your Dash \[la]https://kapeli.com/dash\[ra] docsets are installed.
2828
If undefined, its value is assumed to be \fB\fC$XDG_DATA_HOME/dasht/docsets/\fR
2929
or, if \fB\fCXDG_DATA_HOME\fR is undefined, \fB\fC$HOME/.local/share/dasht/docsets/\fR\&.
30+
.TP
31+
\fB\fCDASHT_CACHE_DIR\fR
32+
Defines the filesystem location where download links and downloaded archives are cached.
33+
If undefined, its value is assumed to be \fB\fC$XDG_CACHE_HOME/dasht/\fR
34+
or, if \fB\fCXDG_CACHE_HOME\fR is also undefined, \fB\fC$HOME/.cache/dasht/\fR\&.
3035
.SH SEE ALSO
3136
.PP
3237
.BR dasht-docsets-extract (1),

0 commit comments

Comments
 (0)