download_file: return normalised absolute path

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2021-02-06 17:38:37 +01:00
parent 5294d00ae3
commit ccac62dd72
2 changed files with 5 additions and 4 deletions

View File

@ -30,7 +30,7 @@ BOTCOMMANDS="-h help init start stop status suspendback resumeback killb
# 8 - curl/wget missing
# 10 - not bash!
#
#### $$VERSION$$ v1.41-dev-6-g0702d58
#### $$VERSION$$ v1.41-dev-9-g5294d00
##################################################################
# are we running in a terminal?
@ -457,7 +457,8 @@ download_file() {
file="${DATADIR:-.}/${file//\//-}"
[ -f "${file}" ] && file="$(mktemp -p "${DATADIR:-.}" "XXXXX-${file##*/}" )"
getJson "${url}" >"${file}" || return
printf '%s\n' "${file}"
# output absolute file path
printf "%s\n" "$(cd "${file%/*}" >/dev/null 2>&1 && pwd)/${file##*/}"
}

View File

@ -539,7 +539,7 @@ edit_html_message "${CHAT[ID]}" "${saved-id}" "this is <b>html</b> text"
### Get files from Telegram
##### download_file
`download_file` download a file to DATADIR and returns the PATH to the file, main use is to download files send to chats.
`download_file` download a file to `DATADIR` and returns the local `path` to the file on disc, main use is to download files send to chats.
I tried to be as compatible as possible with old function `download`.
*usage:* download_file path_to_ile prosed_filename
@ -1627,5 +1627,5 @@ The name of your bot is available as bash variable "$ME", there is no need to ca
#### [Prev Best Practice](5_practice.md)
#### [Next Notes for Developers](7_develop.md)
#### $$VERSION$$ v1.41-dev-8-gb91e96d
#### $$VERSION$$ v1.41-dev-9-g5294d00