Scan files with clamdscan #77
@ -9,7 +9,7 @@ import files.signals
|
||||
def scan_selected_files(self, request, queryset):
|
||||
"""Scan selected files."""
|
||||
for instance in queryset:
|
||||
files.signals._initiate_scan(instance)
|
||||
files.signals.schedule_scan(instance)
|
||||
|
||||
|
||||
class FileValidationInlineAdmin(admin.StackedInline):
|
||||
|
@ -16,8 +16,9 @@ def _record_changes(sender: object, instance: files.models.File, **kwargs: objec
|
||||
instance.record_status_change(was_changed, old_state, **kwargs)
|
||||
|
||||
|
||||
def _initiate_scan(file: files.models.File) -> None:
|
||||
logger.info('Initiating a scan for file pk=%s', file.pk)
|
||||
def schedule_scan(file: files.models.File) -> None:
|
||||
"""Schedule a scan of a given file."""
|
||||
logger.info('Scheduling a scan for file pk=%s', file.pk)
|
||||
files.tasks.clamdscan(file_id=file.pk, creator=file, verbose_name=file.source.name)
|
||||
|
||||
|
||||
@ -28,4 +29,4 @@ def _scan_new_file(
|
||||
if not created:
|
||||
return
|
||||
|
||||
_initiate_scan(instance)
|
||||
schedule_scan(instance)
|
||||
|
Loading…
Reference in New Issue
Block a user