1
0
forked from ScoDoc/ScoDoc

essai avec last_modified

This commit is contained in:
Jean-Marie Place 2021-12-11 17:55:08 +01:00
parent 4f8f327cb6
commit 235ca69a82
2 changed files with 10 additions and 1 deletions

View File

@ -269,6 +269,11 @@ class Logo:
else:
return f'<logo name="{self.logoname}" width="{self.mm[0]}mm"">'
def last_modified(self):
path = Path(self.filepath)
dt = path.stat().st_mtime
return path.stat().st_mtime
def guess_image_type(stream) -> str:
"guess image type from header in stream"

View File

@ -215,7 +215,9 @@ SMALL_SIZE = (200, 200)
def _return_logo(name="header", dept_id="", small=False, strict: bool = True):
# stockée dans /opt/scodoc-data/config/logos donc servie manuellement ici
logo = sco_logos.find_logo(name, dept_id, strict)
# from app.scodoc.sco_photos import _http_jpeg_file
logo = sco_logos.find_logo(name, dept_id, strict).select()
if logo is not None:
suffix = logo.suffix
if small:
@ -232,6 +234,8 @@ def _return_logo(name="header", dept_id="", small=False, strict: bool = True):
stream.seek(0)
return send_file(stream, mimetype=f"image/{fmt}")
else:
# return _http_jpeg_file(logo.filepath)
# ... replaces ...
return send_file(
logo.filepath,
mimetype=f"image/{suffix}",