feed mail: use FileContent to avoid SuspiciousOperation (#59894)
This commit is contained in:
parent
f934f78403
commit
2a287e61b9
|
@ -17,7 +17,7 @@
|
||||||
import os
|
import os
|
||||||
from optparse import make_option
|
from optparse import make_option
|
||||||
|
|
||||||
from django.core.files import File
|
from django.core.files.base import ContentFile
|
||||||
from django.core.management.base import BaseCommand, CommandError
|
from django.core.management.base import BaseCommand, CommandError
|
||||||
|
|
||||||
from ...models import Mail
|
from ...models import Mail
|
||||||
|
@ -35,7 +35,7 @@ class Command(BaseCommand):
|
||||||
continue
|
continue
|
||||||
if not open(filepath).read(5) == '%PDF-':
|
if not open(filepath).read(5) == '%PDF-':
|
||||||
continue
|
continue
|
||||||
mail = Mail(content=File(open(filepath)))
|
mail = Mail(content=ContentFile(open(filepath).read(), name=os.path.basename(filepath)))
|
||||||
mail.scanner_category = kwargs.get('category')
|
mail.scanner_category = kwargs.get('category')
|
||||||
mail.save()
|
mail.save()
|
||||||
count += 1
|
count += 1
|
||||||
|
|
Loading…
Reference in New Issue