Projet

Général

Profil

Bug #42236

fichiers stoqués "opaque" vs nettoyage

Ajouté par Frédéric Péters il y a environ 4 ans. Mis à jour il y a environ 4 ans.

Statut:
Fermé
Priorité:
Normal
Assigné à:
Version cible:
-
Début:
29 avril 2020
Echéance:
% réalisé:

0%

Temps estimé:
Patch proposed:
Oui
Planning:
Non

Description

Exception:
  type = '<class 'TypeError'>', value = 'join() argument must be str or bytes, not 'NoneType''

Stack trace (most recent call first):
  File "/usr/lib/python3.5/genericpath.py", line 143, in _check_arg_types
   141         else:
   142             raise TypeError('%s() argument must be str or bytes, not %r' %
>  143                             (funcname, s.__class__.__name__)) from None
   144     if hasstr and hasbytes:
   145         raise TypeError("Can't mix strings and bytes in path components") from None

  File "/usr/lib/python3.5/posixpath.py", line 89, in join
    87                 path += sep + b
    88     except (TypeError, AttributeError, BytesWarning):
>   89         genericpath._check_arg_types('join', a, *p)
    90         raise
    91     return path

  File "/usr/lib/python3/dist-packages/wcs/qommon/upload_storage.py", line 65, in get_filename
    63             raise AttributeError('filename')
    64         basedir = os.path.join(get_publisher().app_dir, 'uploads')
>   65         return os.path.join(basedir, self.qfilename)
    66
    67     def get_content(self):

  File "/usr/lib/python3/dist-packages/wcs/formdef.py", line 1609, in accumulate_filenames
  1607                         (formdata.workflow_data or {}).values()):
  1608                     if is_upload(field_data):
> 1609                         yield field_data.get_filename()
  1610                 for part in formdata.iter_evolution_parts():
  1611                     if is_attachment(part):


Fichiers

Révisions associées

Révision 3827c81c (diff)
Ajouté par Thomas Noël il y a environ 4 ans

upload_storage: handle empty qfilename, for non-local storage (#42236)

Révision d66eab7c (diff)
Ajouté par Thomas Noël il y a environ 4 ans

upload_storage: clarify get_filename function, renaming it get_fs_filename (#42236)

Historique

#1

Mis à jour par Thomas Noël il y a environ 4 ans

  • Assigné à mis à Thomas Noël
#2

Mis à jour par Thomas Noël il y a environ 4 ans

#3

Mis à jour par Frédéric Péters il y a environ 4 ans

Je pense que je serais plus à l'aise avec juste

     def get_filename(self):
+        if hasattr(self, 'storage_attrs'):  # alternative storage
+            return None
         if not hasattr(self, 'qfilename'):
             raise AttributeError('filename')

(pour reprendre le code comme il est dans get_content) (même s'il y aurait à redire et qu'on pourrait imaginer à un moment qu'il y ait une autre classe de stockage local et que cette condition se révélera alors un vilain raccourci à revoir).

(je serais aussi presque à suggérer de renommer la méthode en get_fs_filepath(), pour ne pas confondre le nom communiqué là avec le "nom de fichier" affiché à l'usager).

#5

Mis à jour par Frédéric Péters il y a environ 4 ans

  • Statut changé de Solution proposée à Solution validée
#6

Mis à jour par Thomas Noël il y a environ 4 ans

  • Statut changé de Solution validée à Résolu (à déployer)
commit d66eab7cd92889360158b1b532ba6ec52daeb9d1
Author: Thomas NOEL <tnoel@entrouvert.com>
Date:   Sun May 3 16:42:22 2020 +0200

    upload_storage: clarify get_filename function, renaming it get_fs_filename (#42236)

commit 3827c81c1d81a7cdb0cf87655750aa8b410735af
Author: Thomas NOEL <tnoel@entrouvert.com>
Date:   Wed Apr 29 10:50:05 2020 +0200

    upload_storage: handle empty qfilename, for non-local storage (#42236)

#7

Mis à jour par Frédéric Péters il y a environ 4 ans

  • Statut changé de Résolu (à déployer) à Solution déployée

Formats disponibles : Atom PDF