Files
zulip/tools/clean-emoji-cache
Aditya Bansal a20249b126 tooling: Add tool to clear unused emoji cache.
In this commit, we are adding a new tool which can be used to
clear out the emoji cache. Cache cleanup is a good thing to in
general and as well helps keep travis cache small (meaning faster
builds).

Credits to @HarshitOnGitHub as well for suggesting the use of
emoji symlink.
2017-06-22 19:17:12 -04:00

24 lines
916 B
Python
Executable File

#!/usr/bin/env python
from __future__ import absolute_import
from __future__ import print_function
import os
import subprocess
import sys
ZULIP_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
EMOJI_CACHE_SYMLINK = os.path.join(ZULIP_PATH, 'static', 'generated', 'emoji')
EMOJI_CACHE_PATH = "/srv/zulip-emoji-cache"
if "--travis" in sys.argv:
EMOJI_CACHE_PATH = os.path.join(os.environ["HOME"], "zulip-emoji-cache")
curr_emoji_cache_dir = os.path.dirname(os.path.realpath(EMOJI_CACHE_SYMLINK))
for cache_dir_base in os.listdir(EMOJI_CACHE_PATH):
emoji_cache_dir = os.path.join(EMOJI_CACHE_PATH, cache_dir_base)
if emoji_cache_dir not in curr_emoji_cache_dir:
print("Cleaning unused emoji cache dir %s" % (emoji_cache_dir,))
subprocess.check_call(["sudo", "rm", "-rf", emoji_cache_dir])
else:
print("Keeping used emoji cache dir %s" % (emoji_cache_dir,))