From f7aaa1363c724b6e272ae5137a2941f8a334b6fb Mon Sep 17 00:00:00 2001 From: Roland Date: Wed, 14 Dec 2022 19:25:05 -0700 Subject: [PATCH] Always fetching mimetype. Special handling for .stl files. --- wrolpi/common.py | 3 +-- wrolpi/files/lib.py | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/wrolpi/common.py b/wrolpi/common.py index 95e38fcf..674d42c2 100644 --- a/wrolpi/common.py +++ b/wrolpi/common.py @@ -813,8 +813,7 @@ def apply_modelers(files, session: Session): # Group all files by their common name (without the suffix). groups = {} for file in files: - if not file.mimetype: - file.mimetype = get_mimetype(file.path) + file.mimetype = get_mimetype(file.path) stem, _ = split_path_stem_and_suffix(file.path) try: groups[stem].append(file) diff --git a/wrolpi/files/lib.py b/wrolpi/files/lib.py index 5a9426a1..ed0d0e92 100644 --- a/wrolpi/files/lib.py +++ b/wrolpi/files/lib.py @@ -108,6 +108,10 @@ def _mimetype_suffix_map(path: Path, mimetype: str): return 'text/vtt' if suffix.endswith('.csv'): return 'text/csv' + if suffix.endswith('.html') or suffix.endswith('.htm'): + return 'text/html' + if suffix.endswith('.stl'): + return 'application/sta' return mimetype