Scan files with clamdscan #77
@ -9,7 +9,7 @@ import files.signals
|
|||||||
def scan_selected_files(self, request, queryset):
|
def scan_selected_files(self, request, queryset):
|
||||||
"""Scan selected files."""
|
"""Scan selected files."""
|
||||||
for instance in queryset:
|
for instance in queryset:
|
||||||
files.signals._initiate_scan(instance)
|
files.signals.schedule_scan(instance)
|
||||||
|
|
||||||
|
|
||||||
class FileValidationInlineAdmin(admin.StackedInline):
|
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)
|
instance.record_status_change(was_changed, old_state, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def _initiate_scan(file: files.models.File) -> None:
|
def schedule_scan(file: files.models.File) -> None:
|
||||||
logger.info('Initiating a scan for file pk=%s', file.pk)
|
"""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)
|
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:
|
if not created:
|
||||||
return
|
return
|
||||||
|
|
||||||
_initiate_scan(instance)
|
schedule_scan(instance)
|
||||||
|
Loading…
Reference in New Issue
Block a user