From ffa28d158997ac2f0f0dabeae2fe8682f2a6b2d9 Mon Sep 17 00:00:00 2001 From: Wu Tingfeng Date: Sun, 20 Nov 2022 22:23:05 +0800 Subject: [PATCH] Create sources_non_forked_cache folder if it does not exist yet --- update_plugins.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/update_plugins.py b/update_plugins.py index e71905cf..d045501c 100644 --- a/update_plugins.py +++ b/update_plugins.py @@ -7,13 +7,14 @@ except ImportError: futures = None import re -import zipfile import shutil import tempfile -import requests - +import zipfile +from distutils.dir_util import copy_tree from os import path +import requests + # --- Globals ---------------------------------------------- PLUGINS = """ auto-pairs https://github.com/jiangmiao/auto-pairs @@ -67,7 +68,8 @@ dracula https://github.com/dracula/vim GITHUB_ZIP = "%s/archive/master.zip" -SOURCE_DIR = path.join(path.dirname(__file__), "sources_non_forked") +FALLBACK_SOURCE_DIR = path.join(path.dirname(__file__), "sources_non_forked") +SOURCE_DIR = path.join(path.dirname(__file__), "sources_non_forked_cache") def download_extract_replace(plugin_name, zip_path, temp_dir, source_dir): @@ -108,6 +110,9 @@ def update(plugin): if __name__ == "__main__": temp_directory = tempfile.mkdtemp() + if not path.isdir(SOURCE_DIR): + copy_tree(FALLBACK_SOURCE_DIR, SOURCE_DIR) + try: if futures: with futures.ThreadPoolExecutor(16) as executor: