diff --git a/api/funkwhale_api/common/tasks.py b/api/funkwhale_api/common/tasks.py index c7deee7f5..74ce3b0e1 100644 --- a/api/funkwhale_api/common/tasks.py +++ b/api/funkwhale_api/common/tasks.py @@ -80,9 +80,10 @@ def fetch_remote_attachment(attachment, filename=None, save=True): for chunk in r.iter_content(): tf.write(chunk) tf.seek(0) - attachment.file.save( - filename or attachment.url.split("/")[-1], File(tf), save=save - ) + if not filename: + filename = attachment.url.split("/")[-1] + filename = filename[-50:] + attachment.file.save(filename, File(tf), save=save) @celery.app.task(name="common.prune_unattached_attachments") diff --git a/api/tests/common/test_views.py b/api/tests/common/test_views.py index 0ca7cbfd9..358d85736 100644 --- a/api/tests/common/test_views.py +++ b/api/tests/common/test_views.py @@ -216,6 +216,27 @@ def test_attachment_proxy_redirects_original( assert response["Location"] == urls[expected] +def test_attachment_proxy_dont_crash_on_long_filename( + factories, logged_in_api_client, avatar, r_mock, now +): + long_filename = "a" * 400 + attachment = factories["common.Attachment"]( + file=None, url="https://domain/{}.jpg".format(long_filename) + ) + + avatar_content = avatar.read() + r_mock.get(attachment.url, body=io.BytesIO(avatar_content)) + proxy_url = reverse("api:v1:attachments-proxy", kwargs={"uuid": attachment.uuid}) + + response = logged_in_api_client.get(proxy_url, {"next": next}) + attachment.refresh_from_db() + + assert response.status_code == 302 + assert attachment.file.read() == avatar_content + assert attachment.file.name.endswith("/{}.jpg".format("a" * 46)) + assert attachment.last_fetch_date == now + + def test_attachment_create(logged_in_api_client, avatar): actor = logged_in_api_client.user.create_actor() url = reverse("api:v1:attachments-list") diff --git a/front/src/components/audio/album/Card.vue b/front/src/components/audio/album/Card.vue index 67d1eb706..6be2dc37c 100644 --- a/front/src/components/audio/album/Card.vue +++ b/front/src/components/audio/album/Card.vue @@ -1,109 +1,51 @@ diff --git a/front/src/components/library/Albums.vue b/front/src/components/library/Albums.vue index 2fd3ec783..8508762cc 100644 --- a/front/src/components/library/Albums.vue +++ b/front/src/components/library/Albums.vue @@ -51,10 +51,8 @@ class="ui stackable three column doubling grid">
+ class="ui app-cards cards"> diff --git a/front/src/components/library/ArtistDetail.vue b/front/src/components/library/ArtistDetail.vue index 1dfbdd0d2..725bedac0 100644 --- a/front/src/components/library/ArtistDetail.vue +++ b/front/src/components/library/ArtistDetail.vue @@ -21,8 +21,8 @@

Albums by this artist

-
- +
+
-
+
diff --git a/front/src/components/playlists/Card.vue b/front/src/components/playlists/Card.vue index 39b8a583f..081624c25 100644 --- a/front/src/components/playlists/Card.vue +++ b/front/src/components/playlists/Card.vue @@ -1,45 +1,24 @@ @@ -53,41 +32,18 @@ export default { PlayButton }, computed: { - coversStyle () { + images () { let self = this let urls = this.playlist.album_covers.map((url) => { - url = self.$store.getters['instance/absoluteUrl'](url) - return `url("${url}")` + return self.$store.getters['instance/absoluteUrl'](url) }).slice(0, 4) - return { - 'background-image': urls.join(', ') + while (urls.length < 4) { + urls.push( + '../../../assets/audio/default-cover.png' + ) } + return urls } } } - - - - diff --git a/front/src/components/playlists/CardList.vue b/front/src/components/playlists/CardList.vue index 44504a573..8ed740568 100644 --- a/front/src/components/playlists/CardList.vue +++ b/front/src/components/playlists/CardList.vue @@ -1,15 +1,8 @@