fix: Return error message if logs are nonexistent or empty
This commit is contained in:
6
main.py
6
main.py
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user