mirror of
https://github.com/zulip/zulip.git
synced 2026-06-21 21:32:29 +08:00
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.
This commit is contained in:
parent
0b03fd97a2
commit
a20249b126
23
tools/clean-emoji-cache
Executable file
23
tools/clean-emoji-cache
Executable file
@ -0,0 +1,23 @@
|
||||
#!/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,))
|
||||
Loading…
Reference in New Issue
Block a user