Get the original MIME type for symlinks.

If the target resource is a symbolic link, then `get_mime_type` should
retrieve the MIME type of the linked resource.
This commit is contained in:
Fabio Manganiello 2024-08-23 00:07:38 +02:00
parent 1e9418b072
commit 0010342fb7
Signed by untrusted user: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -413,7 +413,11 @@ def get_mime_type(resource: str) -> Optional[str]:
)
if mime:
return mime.mime_type if hasattr(mime, 'mime_type') else mime # type: ignore
mime_type = mime.mime_type if hasattr(mime, 'mime_type') else mime # type: ignore
if mime_type == 'inode/symlink':
mime_type = get_mime_type(os.path.realpath(resource))
return mime_type
return None