upgrade-zulip: Clean up legacy google emoji icons.

Because we renamed the "google" iconset to be the modern Google set,
not what is now called the "googleblob" icon set, we need to make sure
that our usually correct policy of not overwriting image files under
`prod-static/` doesn't apply to files potentially being copied in for
the emoji images.

We fix this by just deleting the `images-google-64` directory on
upgrade if it contains the googleblob version of the "hotdog" emoji.

Fixes #10038.
This commit is contained in:
Tim Abbott 2018-10-12 16:23:50 -07:00
parent 3c2f49edaa
commit 608173657d

View File

@ -5,6 +5,7 @@
# always run from the new version of Zulip, so any bug fixes take
# effect on the very next upgrade.
import argparse
import hashlib
import subprocess
import os
import sys
@ -77,6 +78,18 @@ subprocess.check_call([os.path.join(deploy_path, "scripts", "lib", "install-node
subprocess.check_call([os.path.join(deploy_path, "scripts", "setup", "generate_secrets.py"),
"--production"])
# Unpleasant migration: Remove any legacy deployed copies of
# images-google-64 from before we renamed that emojiset to
# "googleblob":
emoji_path = "/home/zulip/prod-static/generated/emoji/images-google-64/1f32d.png"
if os.path.exists(emoji_path):
with open(emoji_path, "rb") as f:
emoji_data = f.read()
emoji_sha = hashlib.sha1(emoji_data).hexdigest()
if emoji_sha == "47033121dc20b376e0f86f4916969872ad22a293":
import shutil
shutil.rmtree("/home/zulip/prod-static/generated/emoji/images-google-64")
# And then, building/installing the static assets.
if args.from_git:
# Note: The fact that this is before we apply puppet changes means