fix: caching & keep configuration file

This commit is contained in:
administrateur 2025-03-30 08:13:04 +02:00
parent 56c25df154
commit b7e9d4d1e6

View File

@ -36,10 +36,14 @@ def obscure_password(password):
return result.stdout.strip() return result.stdout.strip()
def write_rclone_config(): def write_rclone_config():
config_dir = "/tmp/rclone" config_dir = "/cache/rclone"
os.makedirs(config_dir, exist_ok=True) os.makedirs(config_dir, exist_ok=True)
config_path = os.path.join(config_dir, "rclone.conf") config_path = os.path.join(config_dir, "rclone.conf")
if os.path.exists(config_path):
log_debug(f"Reusing existing rclone config at {config_path}")
return config_path
obscured_password = obscure_password(NEXTCLOUD_PASSWORD) obscured_password = obscure_password(NEXTCLOUD_PASSWORD)
with open(config_path, "w") as f: with open(config_path, "w") as f:
@ -52,6 +56,7 @@ pass = {obscured_password}
encoding = Slash,BackSlash,Colon,Dot encoding = Slash,BackSlash,Colon,Dot
""") """)
log_debug(f"Created new rclone config at {config_path}")
return config_path return config_path
def rclone_sync(website, local_path): def rclone_sync(website, local_path):
@ -93,7 +98,7 @@ def build_mkdocs():
log_debug(f"Build already active for website: {website}") log_debug(f"Build already active for website: {website}")
return jsonify({"status": "busy", "message": f"Build already active: {website}"}), 429 return jsonify({"status": "busy", "message": f"Build already active: {website}"}), 429
tmp_path = f"/tmp/{website}" tmp_path = f"/cache/{website}"
compile_path = f"{tmp_path}#compile" compile_path = f"{tmp_path}#compile"
final_path = f"/srv/{website}" final_path = f"/srv/{website}"
src = os.path.join(tmp_path, "mkdocs.yml") src = os.path.join(tmp_path, "mkdocs.yml")