Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
12 changes: 1 addition & 11 deletions app/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,8 @@ def presign_put(extension: str) -> dict[str, str]:


def public_url(key: str) -> str:
"""Resolve a stored S3 key to a public HTTPS URL.

Legacy-filename shim: rows written by the pre-S3 code stored bare
filenames like ``<uuid>_<name>.png``. We deploy this code before
running ``scripts/migrate_uploads_to_s3.py``, so during the cutover
window we'll see both bare filenames and ``books/<uuid>.<ext>`` keys.
Once the migration runs, every row carries the prefix and the
``"/" not in key`` branch becomes dead code — remove it then.
"""
"""Resolve a stored S3 key to a public HTTPS URL."""
if not key:
return ""
if "/" not in key:
key = f"{UPLOAD_PREFIX}{key}"
base = current_app.config["S3_PUBLIC_BASE_URL"].rstrip("/")
return f"{base}/{key}"
7 changes: 0 additions & 7 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ export DATABASE_URL="postgresql+psycopg://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:$
# task sees `head` and no-ops.
flask db upgrade

# One-shot data migration: copy the legacy disk-based book covers into S3
# and prefix the DB rows with `books/`. Idempotent — re-running is a fast
# no-op once every file is in S3 and every row is prefixed. Concurrent
# boots are safe because both phases tolerate redoing already-done work.
# Removable once `app/static/uploads/` is deleted from the repo.
python scripts/migrate_uploads_to_s3.py

# `--access-logfile -` writes access logs to stdout so they land in
# CloudWatch via the awslogs driver. 3 sync workers fits 1 vCPU comfortably.
exec gunicorn \
Expand Down
130 changes: 0 additions & 130 deletions scripts/migrate_uploads_to_s3.py

This file was deleted.