Default undated photo uploads to today

This commit is contained in:
2026-09-20 02:30:32 +03:30
parent cf46d62ede
commit b024474915
3 changed files with 10 additions and 8 deletions
+4 -4
View File
@@ -347,6 +347,7 @@ def create_app(data_dir=None, token=None):
if kind == "snippet":
digest.update(b"\0snippet\0" + text.encode())
temporary = Path(tempfile.mkdtemp(dir=data / "temporary"))
received_at = datetime.now(timezone.utc)
try:
(temporary / "originals").mkdir()
(temporary / "images").mkdir()
@@ -359,7 +360,8 @@ def create_app(data_dir=None, token=None):
embedded_date = web_image(raw, temporary / "images" / f"{index:02}.jpg")
if kind == "photo":
capture_dates.append(batch_date or
(supplied_dates[index] if supplied_dates else embedded_date))
(supplied_dates[index] if supplied_dates else embedded_date) or
received_at)
except (UnidentifiedImageError, OSError, ValueError, SyntaxError,
Image.DecompressionBombError, Image.DecompressionBombWarning,
ImageCms.PyCMSError):
@@ -374,7 +376,7 @@ def create_app(data_dir=None, token=None):
normalized_dates = "\n".join(taken.isoformat() for taken in supplied_dates)
digest.update(b"\0photo_dates\0" + normalized_dates.encode())
job = digest.hexdigest()
date = datetime.now(timezone.utc).isoformat()
date = received_at.isoformat()
manifest = {"id": job, "date": date, "caption": caption,
"highlight": highlight, "count": len(photos)}
if ((batch_date or supplied_dates) and undated_job != job and
@@ -384,8 +386,6 @@ def create_app(data_dir=None, token=None):
manifest.update(kind=kind, text=text)
atomic_json(temporary / "manifest.json", manifest)
if kind == "photo":
if any(taken is None for taken in capture_dates):
abort(400, "Photo capture date is missing; send date_taken or photo_dates")
capture_dates = distinct_photo_dates(capture_dates)
manifest["capture_dates"] = [taken.isoformat() for taken in capture_dates]
atomic_json(temporary / "manifest.json", manifest)