plugin attachment: remove "path" from attachment once used:
"path" refers to a local path of a file, we don't want to store it in database as the file may be in a temporary location, or even be a temporary file. So once the file has been uploaded, we remove it.
This commit is contained in:
parent
3686d7e036
commit
4c474efb3d
1 changed files with 7 additions and 3 deletions
|
|
@ -59,15 +59,19 @@ class AttachPlugin:
|
|||
|
||||
for attachment in attachments:
|
||||
try:
|
||||
path = Path(attachment["path"])
|
||||
# we pop path because we don't want it to be stored, as the image can be
|
||||
# only in a temporary location
|
||||
path = Path(attachment.pop("path"))
|
||||
except KeyError:
|
||||
log.warning("no path in attachment: {attachment}")
|
||||
to_delete.append(attachment)
|
||||
continue
|
||||
|
||||
if "url" in attachment:
|
||||
log.warning("invalid attachment: unknown URL")
|
||||
to_delete.append(attachment)
|
||||
url = attachment.pop('url')
|
||||
log.warning(
|
||||
f"unexpected URL in attachment: {url!r}\nattachment: {attachment}"
|
||||
)
|
||||
|
||||
try:
|
||||
name = attachment["name"]
|
||||
|
|
|
|||
Loading…
Reference in a new issue