save path

This commit is contained in:
leo 2023-02-28 17:30:34 +01:00
parent f1a68c0946
commit b36314ff1e
Signed by: leo
GPG Key ID: 0DD993BFB2B307DB

View File

@ -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)