mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-21 03:27:25 -06:00
[ADD] support old CentOS' magic module
[FIX] handle empty binary fields correctly
This commit is contained in:
parent
259914a27c
commit
ddb47661fb
@ -42,10 +42,15 @@ class IrAttachment(Model):
|
|||||||
extension = ''
|
extension = ''
|
||||||
if filename_field and this[filename_field]:
|
if filename_field and this[filename_field]:
|
||||||
filename, extension = os.path.splitext(this[filename_field])
|
filename, extension = os.path.splitext(this[filename_field])
|
||||||
|
if not this[binary_field]:
|
||||||
|
result[this.id] = False
|
||||||
|
continue
|
||||||
if not extension:
|
if not extension:
|
||||||
try:
|
try:
|
||||||
import magic
|
import magic
|
||||||
ms = magic.open(magic.MAGIC_MIME_TYPE)
|
ms = magic.open(
|
||||||
|
hasattr(magic, 'MAGIC_MIME_TYPE')
|
||||||
|
and magic.MAGIC_MIME_TYPE or magic.MAGIC_MIME)
|
||||||
ms.load()
|
ms.load()
|
||||||
mimetype = ms.buffer(
|
mimetype = ms.buffer(
|
||||||
base64.b64decode(this[binary_field]))
|
base64.b64decode(this[binary_field]))
|
||||||
|
Loading…
Reference in New Issue
Block a user