From b36314ff1e3337cff08c58bd1d780ee5ae5c6acc Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 28 Feb 2023 17:30:34 +0100 Subject: [PATCH] save path --- clone_for_markdown.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/clone_for_markdown.py b/clone_for_markdown.py index c724839..c0a48c4 100644 --- a/clone_for_markdown.py +++ b/clone_for_markdown.py @@ -11,6 +11,7 @@ return : The name of the folder containing the cloned repo """ PATH_PREFIX = "/var/lib/gitea/git/repositories" +CACHE_FOLDER_PATH = "/var/lib/gitea/markdown_cache" #PATH_PREFIX = ".." import sys @@ -24,10 +25,13 @@ repo_path = sys.argv[1].split('/',3) if(len(repo_path)<2): sys.exit("Wrong path format passed") -repo_name = repo_path[2] +repo_name = CACHE_FOLDER_PATH+repo_path[2] repo_path = "/".join(repo_path[:3]) repo_path = PATH_PREFIX + repo_path +if not os.path.isdir(CACHE_FOLDER_PATH): + os.makedirs(CACHE_FOLDER_PATH) + if not os.path.isdir(repo_name): subprocess.run(["git", "clone", repo_path, repo_name], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)