modified: app.py
This commit is contained in:
15
app.py
15
app.py
@@ -300,19 +300,20 @@ def retrieve_command(command_uuid):
|
|||||||
"""Retrieve stored command by UUID (JSON response for plugin)"""
|
"""Retrieve stored command by UUID (JSON response for plugin)"""
|
||||||
cleanup_expired_commands()
|
cleanup_expired_commands()
|
||||||
|
|
||||||
|
# Keep lock for entire operation to prevent race conditions
|
||||||
with storage_lock:
|
with storage_lock:
|
||||||
command_data = command_storage.get(command_uuid)
|
command_data = command_storage.get(command_uuid)
|
||||||
|
|
||||||
if not command_data:
|
if not command_data:
|
||||||
return jsonify({'error': 'Command not found or expired'}), 404
|
return jsonify({'error': 'Command not found or expired'}), 404
|
||||||
|
|
||||||
# Check if expired
|
# Check if expired
|
||||||
if datetime.fromisoformat(command_data['expires_at']) < datetime.now(timezone.utc):
|
if datetime.fromisoformat(command_data['expires_at']) < datetime.now(timezone.utc):
|
||||||
with storage_lock:
|
|
||||||
del command_storage[command_uuid]
|
del command_storage[command_uuid]
|
||||||
return jsonify({'error': 'Command expired'}), 410
|
return jsonify({'error': 'Command expired'}), 410
|
||||||
|
|
||||||
return jsonify(command_data), 200
|
# Return a copy to avoid modification outside lock
|
||||||
|
return jsonify(dict(command_data)), 200
|
||||||
|
|
||||||
# Serve /versions as JSON
|
# Serve /versions as JSON
|
||||||
@app.route('/versions')
|
@app.route('/versions')
|
||||||
|
|||||||
Reference in New Issue
Block a user