Simplify delete_job error handling and remove flash messages
This commit is contained in:
1 parent
91fb9493cc
commit
f327f609e0
1 file changed
+10
-8
+10
-8
@@ -1477,8 +1477,7 @@ def delete_job(job_id):
|
||||
except Exception as e:
|
||||
print(f"ERROR: Failed to delete archive: {e}", file=sys.stderr, flush=True)
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
flash('Job deleted but archive file could not be removed.', 'warning')
|
||||
traceback.print_exc(file=sys.stderr)
|
||||
else:
|
||||
print(f"DEBUG: ZIP file does not exist: {zip_path}", file=sys.stderr, flush=True)
|
||||
|
||||
@@ -1497,24 +1496,27 @@ def delete_job(job_id):
|
||||
del job_queue[job_id]
|
||||
print(f"DEBUG: Saving jobs to disk", file=sys.stderr, flush=True)
|
||||
save_jobs() # Persist job deletion
|
||||
print(f"DEBUG: Job deletion complete, setting flash message", file=sys.stderr, flush=True)
|
||||
flash('Job deleted successfully.', 'success')
|
||||
print(f"DEBUG: Job deletion complete", file=sys.stderr, flush=True)
|
||||
else:
|
||||
print(f"DEBUG: Job status is not completed: {job.get('status')}", file=sys.stderr, flush=True)
|
||||
flash('Only completed jobs can be deleted.', 'error')
|
||||
return "Only completed jobs can be deleted", 400
|
||||
else:
|
||||
print(f"DEBUG: Job not found in queue", file=sys.stderr, flush=True)
|
||||
flash('Job not found.', 'error')
|
||||
return "Job not found", 404
|
||||
except Exception as e:
|
||||
print(f"ERROR: Exception in delete_job: {e}", file=sys.stderr, flush=True)
|
||||
print(f"ERROR: Exception in delete_job: {e}", flush=True)
|
||||
import traceback
|
||||
traceback.print_exc(file=sys.stderr)
|
||||
traceback.print_exc()
|
||||
flash(f'Error deleting job: {str(e)}', 'error')
|
||||
return f"Error deleting job: {str(e)}", 500
|
||||
|
||||
print(f"DEBUG: Redirecting to /jobs", file=sys.stderr, flush=True)
|
||||
return redirect('/jobs')
|
||||
try:
|
||||
return redirect('/jobs')
|
||||
except Exception as e:
|
||||
print(f"ERROR: Redirect failed: {e}", file=sys.stderr, flush=True)
|
||||
return "Job deleted but redirect failed", 200
|
||||
|
||||
@app.route('/completed-jobs')
|
||||
@login_required
|
||||
|
||||
Reference in new issue
Block a user