#9893: Filename + path length greater than 100 truncated on database insertion in Core.Storage --------------------------------------+------------------------------------ Reporter: Refefer | Owner: Type: Bug | Status: new Component: File uploads/storage | Version: master Severity: Normal | Resolution: Keywords: storage, filename | Triage Stage: Accepted Has patch: 1 | Needs documentation: 0 Needs tests: 1 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 --------------------------------------+------------------------------------
Comment (by wdoekes): So, I ran into bug #13314. These are all similar but not quite the same. #9893 -- Filename + path length greater than 100 (when making filenames unique)[[br]] #10410 -- FileField saves one filename on disk and another on DB[[br]] #13314 -- validation does not account for "upload_to" when counting characters This ticket #9893 is about the changed filenames when making them unique. Ticket #13314 is just about the upload_to parameter. For that problem the fix could be done like this: {{{ --- django/db/models/fields/files.py.orig 2013-04-01 17:03:59.752332630 +0200 +++ django/db/models/fields/files.py 2013-04-01 17:08:15.833870239 +0200 @@ -290,6 +290,8 @@ if 'initial' in kwargs: defaults['required'] = False defaults.update(kwargs) + # And deduct the upload_to length from the max_length. + defaults['max_length'] -= len(self.upload_to) return super(FileField, self).formfield(**defaults) class ImageFileDescriptor(FileDescriptor): }}} With this environment: * ImageField with max_length default 100 * An upload_to value of "profile/" (8 characters) Without the fix, I get a DatabaseError for a 99-byte length filename.[[br]] With the fix, I get a nice ValidationError until I reduce the filename to 92 bytes. That should be at least be one less problem, right? This was tested with Django 1.3.7. -- Ticket URL: <https://code.djangoproject.com/ticket/9893#comment:36> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.