Ticket #13857: default-umask.diff

File default-umask.diff, 1.7 KB (added by Simon Litchfield, 14 years ago)

Standardise default umask to match system default, includes doc

  • django/core/files/storage.py

     
    181181                # OK, the file save worked. Break out of the loop.
    182182                break
    183183
    184         if settings.FILE_UPLOAD_PERMISSIONS is not None:
    185             os.chmod(full_path, settings.FILE_UPLOAD_PERMISSIONS)
     184        mode = settings.FILE_UPLOAD_PERMISSIONS
     185        if not mode:
     186            # Read the system default by setting it, then set it back
     187            mode = os.umask(0644)
     188            os.umask(mode)
     189        os.chmod(full_path, mode)
    186190
    187191        return name
    188192
  • docs/topics/http/file-uploads.txt

     
    149149        more information about what these modes mean, see the `documentation for
    150150        os.chmod`_
    151151
    152         If this isn't given or is ``None``, you'll get operating-system
    153         dependent behavior. On most platforms, temporary files will have a mode
    154         of ``0600``, and files saved from memory will be saved using the
    155         system's standard umask.
    156 
     152        Defaults to system's current umask, as returned by `os.umask`_.
     153           
    157154        .. warning::
    158155
    159156            If you're not familiar with file modes, please note that the leading
     
    177174        files."
    178175
    179176.. _documentation for os.chmod: http://docs.python.org/library/os.html#os.chmod
     177.. _os.umask: http://docs.python.org/library/os.html#os.umask
    180178
    181179``UploadedFile`` objects
    182180========================
Back to Top