analyze performance upgrade
This commit is contained in:
@@ -84,7 +84,7 @@ def create_capture(
|
||||
filename: str,
|
||||
ip_address: str,
|
||||
) -> File:
|
||||
"""Create capture metadata, analyze the stored file, and update its status."""
|
||||
"""Create capture metadata and hand the analysis to a background worker."""
|
||||
firmware_version = _required_text(firmware_version, "Firmware version", 100)
|
||||
filename = os.path.basename(_required_text(filename, "Capture filename", 255))
|
||||
if os.path.splitext(filename)[1].lower() not in CAPTURE_EXTENSIONS:
|
||||
@@ -113,10 +113,10 @@ def create_capture(
|
||||
raise ValidationError("This capture is already registered for the device.")
|
||||
raw_dataset = RawDataset.objects.create(file=file_entry)
|
||||
|
||||
from .analyze.security_analysis import analyze_capture
|
||||
from .analyze.security_analysis import start_capture_analysis
|
||||
|
||||
result = analyze_capture(filename, file_entry.id, raw_dataset.id)
|
||||
file_entry.status = "analyzed" if result is not None else "analysis_failed"
|
||||
file_entry.save(update_fields=["status"])
|
||||
logger.info("Capture %s completed with status %s", file_entry.id, file_entry.status)
|
||||
# The analysis reads the whole capture with tshark and can run for many
|
||||
# minutes, so it must not block the upload response.
|
||||
start_capture_analysis(file_entry.id, filename, raw_dataset.id)
|
||||
logger.info("Capture %s registered, analysis queued", file_entry.id)
|
||||
return file_entry
|
||||
|
||||
Reference in New Issue
Block a user