Skip to content
Snippets Groups Projects
Commit 74f1a932 authored by Kristian Klausen's avatar Kristian Klausen :tada:
Browse files

Download the attachment as "attachment" if it fails due to a file I/O error

This can happen if the filename is invalid, ex:
https://bugs.archlinux.org/task/6698 contains a attachment with the
filename "." which wget can't write to:
.: Is a directory
Cannot write to '.' (Is a directory).
parent 2cf3c583
No related branches found
No related tags found
No related merge requests found
......@@ -76,8 +76,12 @@ function download_attachment() {
mkdir -p "attachments/${1}/"{tmp,${2}}
cd "attachments/${1}/tmp"
wget --content-disposition \
"https://bugs.archlinux.org/?getfile=${2}" || { [[ ${?} = 3 ]] && echo "Error downloading attachment: ${2}" && cd .. && rmdir tmp "${2}" && cd ../../ && return; }
options=(--content-disposition)
if [[ ${3:-false} = true ]]; then
options=(--output-document=attachment)
fi
wget "${options[@]}" \
"https://bugs.archlinux.org/?getfile=${2}" || { [[ ${?} = 3 ]] && echo "Error downloading attachment: ${2}" && cd .. && rmdir tmp "${2}" && cd ../../ || exit 1 && [[ ${3:-false} = true ]] && return; download_attachment "${1}" "${2}" "true"; return; }
local files=(*)
filename="${files[0]}"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment