fix: Return error message if logs are nonexistent or empty

This commit is contained in:
2025-09-11 15:28:37 +10:00
parent 2e86e64dd0
commit 6442aa4df6

View File

@@ -1235,7 +1235,11 @@ def settings_action(action):
if action == "logs": if action == "logs":
if not os.path.exists(log_file): if not os.path.exists(log_file):
return jsonify({"error": "Log file not found"}), 404 return redirect("/settings?error=No log file found")
# Check if log file is empty
if os.path.getsize(log_file) == 0:
return redirect("/settings?error=Log file is empty")
try: try:
with open(log_file, 'rb') as f: with open(log_file, 'rb') as f:
response = requests.put(f"https://upload.woodburn.au/{os.path.basename(log_file)}", data=f) response = requests.put(f"https://upload.woodburn.au/{os.path.basename(log_file)}", data=f)