Projet

Général

Profil

0001-pwa-use-icon-file-basename-during-import-49149.patch

Benjamin Dauvergne, 04 mai 2021 14:18

Télécharger (1,41 ko)

Voir les différences:

Subject: [PATCH] pwa: use icon file basename during import (#49149)

Django 2.2.21 introduced the validation of FieldFile.save() name
argument, which cannot contain a path separator anymore. To use the
received FileField value as a base filename, we must apply
os.path.basename() on it first.

ref. https://docs.djangoproject.com/en/3.2/releases/2.2.21/
 combo/apps/pwa/models.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
combo/apps/pwa/models.py
18 18

  
19 19
import base64
20 20
import json
21
import os
21 22

  
22 23
from django.conf import settings
23 24
from django.core import serializers
......
188 189
            decoded_icon = base64.decodebytes(force_bytes(json_entry['icon:base64']))
189 190
            if not default_storage.exists(entry.object.icon.name) or entry.object.icon.read() != decoded_icon:
190 191
                # save new file
191
                entry.object.icon.save(entry.object.icon.name, ContentFile(decoded_icon))
192
                entry.object.icon.save(os.path.basename(entry.object.icon.name), ContentFile(decoded_icon))
192 193

  
193 194

  
194 195
class PushSubscription(models.Model):
195
-