commit 4c74ce4943b08059c18569a234ab50b3a345c298 parent 42e2b007e32d6a716f00f36fa15516827fdbafb6 Author: parazyd <parazyd@dyne.org> Date: Tue, 19 May 2020 13:21:57 +0200 Support meme2 format in autoup and optimize. Diffstat:
M | autoup | | | 24 | ++++++++++++++---------- |
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/autoup b/autoup @@ -56,19 +56,23 @@ esac scp "$1" "${server}:${webroot}/${webdir}/${filename}" || exit 1 if [ "$webdir" = memecache ]; then - memes="$(ssh "$server" find "$webroot/$webdir" -type f -exec basename {} \\';')" - memes="$(printf "$memes" | grep -v memes.meme | sort)" + oldmemes="$(hurl gopher://$server/0/pub/$webdir/memes.meme)" memefile="$(mktemp)" - echo "meme" > "$memefile" - for meme in $memes; do - printf "#%s gopher://%s/%s/pub/%s/%s\n" \ - "$(printf "%s" "$meme" | cut -d. -f1)" \ - "$server" "$(ext2gopher "$meme")" \ - "$webdir" "$meme" >> "$memefile" - done + t="$(mktemp)" + chmod 644 "$memefile" + + printf "%s\n" "$oldmemes" | grep -v ^meme2 > "$t" + printf "#%s gopher://%s/%s/pub/%s/%s %s\n" \ + "$(basename "$filename" | cut -d. -f1)" \ + "${server}" "$(ext2gopher "$filename")" \ + "${webdir}" "$(basename "$filename")" \ + "$(sha512sum "$filename" | cut -d' ' -f1)" >> "$t" + + printf "meme2\n" > "$memefile" + sort "$t" >> "$memefile" scp "$memefile" "${server}:${webroot}/${webdir}/memes.meme" - rm -f "$memefile" + rm -f "$memefile" "$t" fi printf "https://%s/pub/%s/%s\n" "$server" "$webdir" "$filename"