From 0010342fb75913cab0f28d8347073a15ff38ca78 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Fri, 23 Aug 2024 00:07:38 +0200 Subject: [PATCH] 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. --- platypush/utils/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/platypush/utils/__init__.py b/platypush/utils/__init__.py index 3851353f09..a0c29b5d44 100644 --- a/platypush/utils/__init__.py +++ b/platypush/utils/__init__.py @@ -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