Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
run-dev: Support extra MIME types from zerver.lib.mime_types.
Anders Kaseorga9b9ed6c5ba8
diff --git a/tools/run-dev b/tools/run-devindex a8f2afed1f9..2ac1aa3b87a 100755--- a/tools/run-dev+++ b/tools/run-dev@@ -19,11 +19,13 @@ from tools.lib import sanity_checksanity_check.check_venv(__file__)import aiohttp+import aiohttp.web_fileresponsefrom aiohttp import hdrs, webfrom aiohttp.http_exceptions import BadStatusLinefrom scripts.lib.zulip_tools import CYAN, ENDCfrom tools.lib.test_script import add_provision_check_override_param, assert_provisioning_status_ok+from zerver.lib.mime_types import EXTRA_MIME_TYPESfrom zerver.lib.partial import partialif "posix" in os.name and os.geteuid() == 0:@@ -124,6 +126,9 @@ webpack_port = base_port + 3help_center_port = base_port + 4tusd_port = base_port + 5+for mime_type, extension in EXTRA_MIME_TYPES:+ aiohttp.web_fileresponse.CONTENT_TYPES.add_type(mime_type, extension)+os.chdir(os.path.join(os.path.dirname(__file__), ".."))if options.clear_memcached:diff --git a/zerver/lib/mime_types.py b/zerver/lib/mime_types.pyindex 1e8208cc7c0..65d5e4f35af 100644--- a/zerver/lib/mime_types.py+++ b/zerver/lib/mime_types.py@@ -3,13 +3,20 @@ from mimetypes import add_typefrom mimetypes import guess_extension as guess_extensionfrom mimetypes import guess_type as guess_type-add_type("audio/flac", ".flac")-add_type("audio/mp4", ".m4a")-add_type("audio/wav", ".wav")-add_type("audio/webm", ".weba")-add_type("image/apng", ".apng")+EXTRA_MIME_TYPES = [+ ("audio/flac", ".flac"),+ ("audio/mp4", ".m4a"),+ ("audio/wav", ".wav"),+ ("audio/webm", ".weba"),+ ("image/apng", ".apng"),+]if sys.version_info < (3, 11): # nocoverage# https://github.com/python/cpython/issues/89802- add_type("image/avif", ".avif")- add_type("image/webp", ".webp")+ EXTRA_MIME_TYPES += [+ ("image/avif", ".avif"),+ ("image/webp", ".webp"),+ ]++for mime_type, extension in EXTRA_MIME_TYPES:+ add_type(mime_type, extension)