#23759: Storage.get_available_name should preserve all file extensions, not just
the first one
--------------------------------------+--------------------
     Reporter:  thenewguy             |      Owner:  nobody
         Type:  Uncategorized         |     Status:  new
    Component:  File uploads/storage  |    Version:  1.7
     Severity:  Normal                |   Keywords:
 Triage Stage:  Unreviewed            |  Has patch:  0
Easy pickings:  1                     |      UI/UX:  0
--------------------------------------+--------------------
 `get_available_name` only preserves the first file extension.  If the file
 is `foo.tar.gz` then `get_available_name` will return `foo.tar_RANDOM.gz`
 instead of `foo_RANDOM.tar.gz`

 https://github.com/django/django/blob/master/django/core/files/storage.py#L71


 {{{
     def get_available_name(self, name):
         """
         Returns a filename that's free on the target storage system, and
         available for new content to be written to.
         """
         dir_name, file_name = os.path.split(name)
         file_root, file_ext = os.path.splitext(file_name)
         # If the filename already exists, add an underscore and a random 7
         # character alphanumeric string (before the file extension, if one
         # exists) to the filename until the generated filename doesn't
 exist.
         while self.exists(name):
             # file_ext includes the dot.
             name = os.path.join(dir_name, "%s_%s%s" % (file_root,
 get_random_string(7), file_ext))

         return name
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23759>
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/052.71f09b10df776ae66b226116448ae948%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to