mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-04 23:49:16 +02:00
Merge branch 'master' into develop
This commit is contained in:
commit
c58c74d653
14 changed files with 73 additions and 8 deletions
|
@ -1,3 +1,3 @@
|
|||
#!/bin/bash -eux
|
||||
python /app/manage.py collectstatic --noinput
|
||||
gunicorn config.asgi:application -w ${FUNKWHALE_WEB_WORKERS-1} -k uvicorn.workers.UvicornWorker -b 0.0.0.0:5000
|
||||
gunicorn config.asgi:application -w ${FUNKWHALE_WEB_WORKERS-1} -k uvicorn.workers.UvicornWorker -b 0.0.0.0:5000 ${GUNICORN_ARGS-}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import os
|
||||
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.production")
|
||||
os.environ.setdefault("ASGI_THREADS", "5")
|
||||
|
||||
import django # noqa
|
||||
|
||||
|
|
|
@ -270,7 +270,7 @@ DATABASES = {
|
|||
"default": env.db("DATABASE_URL")
|
||||
}
|
||||
DATABASES["default"]["ATOMIC_REQUESTS"] = True
|
||||
DATABASES["default"]["CONN_MAX_AGE"] = env("DB_CONN_MAX_AGE", default=60 * 60)
|
||||
DATABASES["default"]["CONN_MAX_AGE"] = env("DB_CONN_MAX_AGE", default=60 * 5)
|
||||
|
||||
MIGRATION_MODULES = {
|
||||
# see https://github.com/jazzband/django-oauth-toolkit/issues/634
|
||||
|
|
|
@ -72,7 +72,7 @@ def clean_id3_pictures(apic):
|
|||
|
||||
def get_mp4_tag(f, k):
|
||||
if k == "pictures":
|
||||
return f.get("covr")
|
||||
return f.get("covr", [])
|
||||
raw_value = f.get(k, None)
|
||||
|
||||
if not raw_value:
|
||||
|
|
|
@ -320,6 +320,10 @@ def get_file_path(audio_file):
|
|||
)
|
||||
path = "/music" + audio_file.replace(prefix, "", 1)
|
||||
if path.startswith("http://") or path.startswith("https://"):
|
||||
protocol, remainder = path.split("://", 1)
|
||||
hostname, r_path = remainder.split("/", 1)
|
||||
r_path = urllib.parse.quote(r_path)
|
||||
path = protocol + "://" + hostname + "/" + r_path
|
||||
return (settings.PROTECT_FILES_PATH + "/media/" + path).encode("utf-8")
|
||||
# needed to serve files with % or ? chars
|
||||
path = urllib.parse.quote(path)
|
||||
|
|
|
@ -219,6 +219,11 @@ def test_can_get_metadata_from_m4a_file(field, value):
|
|||
assert data.get(field) == value
|
||||
|
||||
|
||||
def test_get_pictures_m4a_empty():
|
||||
pictures = metadata.get_mp4_tag({}, "pictures")
|
||||
assert metadata.clean_mp4_pictures(pictures) == []
|
||||
|
||||
|
||||
def test_can_get_metadata_from_flac_file_not_crash_if_empty():
|
||||
path = os.path.join(DATA_DIR, "sample.flac")
|
||||
data = metadata.Metadata(path)
|
||||
|
|
|
@ -247,6 +247,18 @@ def test_serve_file_in_place_nginx_encode_url(
|
|||
assert response["X-Accel-Redirect"] == expected
|
||||
|
||||
|
||||
def test_serve_s3_nginx_encode_url(mocker, settings):
|
||||
settings.PROTECT_FILE_PATH = "/_protected/media"
|
||||
settings.REVERSE_PROXY_TYPE = "nginx"
|
||||
audio_file = mocker.Mock(url="https://s3.storage.example/path/to/mp3?aws=signature")
|
||||
|
||||
expected = (
|
||||
b"/_protected/media/https://s3.storage.example/path/to/mp3%3Faws%3Dsignature"
|
||||
)
|
||||
|
||||
assert views.get_file_path(audio_file) == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"proxy,serve_path,expected",
|
||||
[
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue