Skip to content
Snippets Groups Projects
Commit ee267260 authored by Bob Mottram's avatar Bob Mottram
Browse files

Handle situations where an old emoji image is overwritten

parent d6436c5a
No related branches found
No related tags found
No related merge requests found
......@@ -96,6 +96,7 @@ function pleroma_setting_emoji {
image_extension='png'
fi
if [ ! $image_extension ]; then
echo $'Invalid image type'
return
fi
......@@ -104,10 +105,15 @@ function pleroma_setting_emoji {
fi
image_filename=$PLEROMA_DIR/priv/static/emoji/${shortcode}.${image_extension}
if [ -f "$image_filename" ]; then
mv "$image_filename" "${image_filename}.prev"
fi
wget "$image_url" -O "$image_filename"
if [ ! -f "$image_filename" ]; then
mv "${image_filename}.prev" "${image_filename}"
return
fi
rm "${image_filename}.prev"
if [[ "$image_url" == *'.jpg' || "$image_url" == *'.jpeg' || "$image_url" == *'.gif' ]]; then
convert "$image_filename" -resize "$emoji_resolution" "$PLEROMA_DIR/priv/static/emoji/${shortcode}.png"
......@@ -786,8 +792,12 @@ function pleroma_add_emoji {
fi
image_filename=$PLEROMA_DIR/priv/static/emoji/${shortcode}.${image_extension}
if [ -f "$image_filename" ]; then
mv "$image_filename" "${image_filename}.prev"
fi
wget "$image_url" -O "$image_filename"
if [ ! -f "$image_filename" ]; then
mv "${image_filename}.prev" "${image_filename}"
dialog --title $"Add Custom Emoji" \
--msgbox $"Unable to download the image" 6 60
return
......
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