mirror of https://github.com/zulip/zulip.git
zulip_tools: Change `purge_unused_caches()` API.
Instead of accepting individual arguments, accept `argparse.Namespace` object as an argument.
This commit is contained in:
parent
8a4c1164b2
commit
4e6b68d02f
|
@ -51,7 +51,7 @@ def main():
|
|||
args = parse_args()
|
||||
caches_in_use = get_caches_in_use(args.threshold_days)
|
||||
purge_unused_caches(
|
||||
EMOJI_CACHE_PATH, caches_in_use, args.threshold_days, args.dry_run, "emoji cache")
|
||||
EMOJI_CACHE_PATH, caches_in_use, args, "emoji cache")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
@ -61,8 +61,7 @@ def main():
|
|||
args = parse_args()
|
||||
caches_in_use = get_caches_in_use(args.threshold_days)
|
||||
purge_unused_caches(
|
||||
NODE_MODULES_CACHE_PATH, caches_in_use, args.threshold_days,
|
||||
args.dry_run, "node modules cache")
|
||||
NODE_MODULES_CACHE_PATH, caches_in_use, args, "node modules cache")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
@ -51,7 +51,7 @@ def main():
|
|||
args = parse_args()
|
||||
caches_in_use = get_caches_in_use(args.threshold_days)
|
||||
purge_unused_caches(
|
||||
VENV_CACHE_DIR, caches_in_use, args.threshold_days, args.dry_run, "venv cache")
|
||||
VENV_CACHE_DIR, caches_in_use, args, "venv cache")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
@ -221,13 +221,13 @@ def get_caches_to_be_purged(caches_dir, caches_in_use, threshold_days):
|
|||
caches_to_purge.add(cache_dir)
|
||||
return caches_to_purge
|
||||
|
||||
def purge_unused_caches(caches_dir, caches_in_use, threshold_days, dry_run, cache_type):
|
||||
# type: (Text, Set[Text], int, bool, Text) -> None
|
||||
def purge_unused_caches(caches_dir, caches_in_use, args, cache_type):
|
||||
# type: (Text, Set[Text], argparse.Namespace, Text) -> None
|
||||
all_caches = set([os.path.join(caches_dir, cache) for cache in os.listdir(caches_dir)])
|
||||
caches_to_purge = get_caches_to_be_purged(caches_dir, caches_in_use, threshold_days)
|
||||
caches_to_purge = get_caches_to_be_purged(caches_dir, caches_in_use, args.threshold_days)
|
||||
caches_to_keep = all_caches - caches_to_purge
|
||||
|
||||
may_be_perform_purging(caches_to_purge, caches_to_keep, cache_type, dry_run)
|
||||
may_be_perform_purging(caches_to_purge, caches_to_keep, cache_type, args.dry_run)
|
||||
print("Done!\n")
|
||||
|
||||
def generate_sha1sum_emoji(zulip_path):
|
||||
|
|
Loading…
Reference in New Issue