|
@@ -794,6 +794,7 @@ def api_archive_info_json_download(name):
|
|
|
if not sudo_exists(info_path):
|
|
if not sudo_exists(info_path):
|
|
|
return jsonify({"error": "info.json introuvable"}), 404
|
|
return jsonify({"error": "info.json introuvable"}), 404
|
|
|
tmp_path = f"/tmp/backupmanager_dl_{name}.info.json"
|
|
tmp_path = f"/tmp/backupmanager_dl_{name}.info.json"
|
|
|
|
|
+ content = None
|
|
|
try:
|
|
try:
|
|
|
result = subprocess.run(["sudo", "rsync", info_path, tmp_path],
|
|
result = subprocess.run(["sudo", "rsync", info_path, tmp_path],
|
|
|
capture_output=True, text=True)
|
|
capture_output=True, text=True)
|
|
@@ -801,13 +802,12 @@ def api_archive_info_json_download(name):
|
|
|
return jsonify({"error": result.stderr.strip()}), 500
|
|
return jsonify({"error": result.stderr.strip()}), 500
|
|
|
with open(tmp_path, "rb") as f:
|
|
with open(tmp_path, "rb") as f:
|
|
|
content = f.read()
|
|
content = f.read()
|
|
|
- os.unlink(tmp_path)
|
|
|
|
|
- from flask import Response as _R
|
|
|
|
|
- return _R(content, mimetype="application/json")
|
|
|
|
|
except Exception as exc:
|
|
except Exception as exc:
|
|
|
- if os.path.exists(tmp_path):
|
|
|
|
|
- os.unlink(tmp_path)
|
|
|
|
|
return jsonify({"error": str(exc)}), 500
|
|
return jsonify({"error": str(exc)}), 500
|
|
|
|
|
+ finally:
|
|
|
|
|
+ subprocess.run(["sudo", "rm", "-rf", tmp_path], capture_output=True)
|
|
|
|
|
+ from flask import Response as _R
|
|
|
|
|
+ return _R(content, mimetype="application/json")
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route("/api/v1/archives/<name>/download")
|
|
@app.route("/api/v1/archives/<name>/download")
|
|
@@ -1094,6 +1094,8 @@ def _do_pull_latest(inst_id, remote_job_id):
|
|
|
os.path.join(backup_dir, archive_name + ".info.json")],
|
|
os.path.join(backup_dir, archive_name + ".info.json")],
|
|
|
check=True)
|
|
check=True)
|
|
|
os.unlink(tmp_info)
|
|
os.unlink(tmp_info)
|
|
|
|
|
+ else:
|
|
|
|
|
+ app.logger.warning(f"Pull {archive_name}: .info.json absent ou inaccessible sur {inst.name}")
|
|
|
|
|
|
|
|
app.logger.info(f"Pull {archive_name} ← {inst.name} OK")
|
|
app.logger.info(f"Pull {archive_name} ← {inst.name} OK")
|
|
|
except Exception as exc:
|
|
except Exception as exc:
|