Skip to content

store downloaded archives in DASHT_CACHE_DIR instead of using DASHT_DOCSETS_DIR #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,11 @@ which defines the filesystem location where your [Dash] docsets are installed.
If undefined, its value is assumed to be `$XDG_DATA_HOME/dasht/docsets/` or,
if `XDG_DATA_HOME` is also undefined, `$HOME/.local/share/dasht/docsets/`.

You may optionally configure the `DASHT_CACHE_DIR` environment variable,
which defines the filesystem location where download links are cached.
If undefined, its value is assumed to be `$XDG_CACHE_HOME/dasht/`
or, if `XDG_CACHE_HOME` is also undefined, `$HOME/.cache/dasht/`.
You may optionally configure the `DASHT_CACHE_DIR` environment variable, which
defines the filesystem location where download links and downloaded docset
archives are cached. If undefined, its value is assumed to be
`$XDG_CACHE_HOME/dasht/` or, if `XDG_CACHE_HOME` is also undefined,
`$HOME/.cache/dasht/`.

## Development

Expand Down
11 changes: 6 additions & 5 deletions bin/dasht-docsets-install
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@
# or, if `XDG_DATA_HOME` is undefined, `$HOME/.local/share/dasht/docsets/`.
#
# `DASHT_CACHE_DIR`
# Defines the filesystem location where download links are cached.
# If undefined, its value is assumed to be `$XDG_CACHE_HOME/dasht/`
# or, if `XDG_CACHE_HOME` is also undefined, `$HOME/.cache/dasht/`.
# Defines the filesystem location where download links and downloaded
# archives are cached. If undefined, its value is assumed to be
# `$XDG_CACHE_HOME/dasht/` or, if `XDG_CACHE_HOME` is also undefined,
# `$HOME/.cache/dasht/`.
#
# ## SEE ALSO
#
Expand Down Expand Up @@ -89,9 +90,9 @@ for docset; do
echo "Install $docset docset [y/N]" | xargs -p | grep -q . || continue

basename="$docset".tgz
tgz="$DASHT_DOCSETS_DIR/$basename"
tgz="$DASHT_CACHE_DIR/$basename"
url="https://kapeli.com/feeds/$basename"

wget -P "$DASHT_DOCSETS_DIR" -N -c "$url"
wget -P "$DASHT_CACHE_DIR" -N -c "$url"
gzip -t "$tgz" && dasht-docsets-extract "$tgz"
done
12 changes: 9 additions & 3 deletions bin/dasht-docsets-remove
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
# If undefined, its value is assumed to be `$XDG_DATA_HOME/dasht/docsets/`
# or, if `XDG_DATA_HOME` is undefined, `$HOME/.local/share/dasht/docsets/`.
#
# `DASHT_CACHE_DIR`
# Defines the filesystem location where download links and downloaded
# archives are cached. If undefined, its value is assumed to be
# `$XDG_CACHE_HOME/dasht/` or, if `XDG_CACHE_HOME` is also undefined,
# `$HOME/.cache/dasht/`.
#
# ## SEE ALSO
#
# dasht-docsets-install(1), dasht-docsets-update(1), dasht-docsets(1), [Dash]
Expand All @@ -51,6 +57,7 @@
# Distributed under the terms of the ISC license (refer to README file).

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

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

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

rootname="$DASHT_DOCSETS_DIR/$docset"
rm -v -f -r "$rootname".docset \
"$rootname".tgz
rm -v -f -r "$DASHT_DOCSETS_DIR/$docset".docset \
"$DASHT_CACHE_DIR/$docset".tgz
done
11 changes: 9 additions & 2 deletions bin/dasht-docsets-update
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
# If undefined, its value is assumed to be `$XDG_DATA_HOME/dasht/docsets/`
# or, if `XDG_DATA_HOME` is undefined, `$HOME/.local/share/dasht/docsets/`.
#
# `DASHT_CACHE_DIR`
# Defines the filesystem location where download links and downloaded
# archives are cached. If undefined, its value is assumed to be
# `$XDG_CACHE_HOME/dasht/` or, if `XDG_CACHE_HOME` is also undefined,
# `$HOME/.cache/dasht/`.
#
# ## SEE ALSO
#
# dasht-docsets-extract(1), dasht-docsets-install(1), dasht-docsets-remove(1),
Expand All @@ -46,15 +52,16 @@
# Distributed under the terms of the ISC license (refer to README file).

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

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

touch -r "$tgz" "$last_modified_at"
wget -P "$DASHT_DOCSETS_DIR" -N "$url"
wget -P "$DASHT_CACHE_DIR" -N "$url"
test "$tgz" -nt "$last_modified_at" && dasht-docsets-extract "$tgz"
rm "$last_modified_at"
done
2 changes: 1 addition & 1 deletion man/man1/dasht-docsets-install.1
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ If undefined, its value is assumed to be \fB\fC$XDG_DATA_HOME/dasht/docsets/\fR
or, if \fB\fCXDG_DATA_HOME\fR is undefined, \fB\fC$HOME/.local/share/dasht/docsets/\fR\&.
.TP
\fB\fCDASHT_CACHE_DIR\fR
Defines the filesystem location where download links are cached.
Defines the filesystem location where download links and downloaded archives are cached.
If undefined, its value is assumed to be \fB\fC$XDG_CACHE_HOME/dasht/\fR
or, if \fB\fCXDG_CACHE_HOME\fR is also undefined, \fB\fC$HOME/.cache/dasht/\fR\&.
.SH SEE ALSO
Expand Down
5 changes: 5 additions & 0 deletions man/man1/dasht-docsets-remove.1
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ Forces the operation by overriding the interactive confirmation prompt.
Defines the filesystem location where your Dash \[la]https://kapeli.com/dash\[ra] docsets are installed.
If undefined, its value is assumed to be \fB\fC$XDG_DATA_HOME/dasht/docsets/\fR
or, if \fB\fCXDG_DATA_HOME\fR is undefined, \fB\fC$HOME/.local/share/dasht/docsets/\fR\&.
.TP
\fB\fCDASHT_CACHE_DIR\fR
Defines the filesystem location where download links and downloaded archives are cached.
If undefined, its value is assumed to be \fB\fC$XDG_CACHE_HOME/dasht/\fR
or, if \fB\fCXDG_CACHE_HOME\fR is also undefined, \fB\fC$HOME/.cache/dasht/\fR\&.
.SH SEE ALSO
.PP
.BR dasht-docsets-install (1),
Expand Down
5 changes: 5 additions & 0 deletions man/man1/dasht-docsets-update.1
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ patterns. If no \fINAME\fPs are given, all available docsets are matched.
Defines the filesystem location where your Dash \[la]https://kapeli.com/dash\[ra] docsets are installed.
If undefined, its value is assumed to be \fB\fC$XDG_DATA_HOME/dasht/docsets/\fR
or, if \fB\fCXDG_DATA_HOME\fR is undefined, \fB\fC$HOME/.local/share/dasht/docsets/\fR\&.
.TP
\fB\fCDASHT_CACHE_DIR\fR
Defines the filesystem location where download links and downloaded archives are cached.
If undefined, its value is assumed to be \fB\fC$XDG_CACHE_HOME/dasht/\fR
or, if \fB\fCXDG_CACHE_HOME\fR is also undefined, \fB\fC$HOME/.cache/dasht/\fR\&.
.SH SEE ALSO
.PP
.BR dasht-docsets-extract (1),
Expand Down