1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #8454: added a FILE_UPLOAD_PERMISSIONS setting to control the permissoin of files uploaded by the built-in file storage system. Thanks, dcwatson.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@8640 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jacob Kaplan-Moss
2008-08-27 22:21:14 +00:00
parent f58217cc02
commit ff420b4364
5 changed files with 88 additions and 14 deletions

View File

@@ -86,9 +86,10 @@ u'custom_storage.2'
# Tests for a race condition on file saving (#4948).
# This is written in such a way that it'll always pass on platforms
# without threading.
import os
import time
from unittest import TestCase
from django.conf import settings
from django.core.files.base import ContentFile
from models import temp_storage
try:
@@ -117,3 +118,15 @@ class FileSaveRaceConditionTest(TestCase):
temp_storage.delete('conflict')
temp_storage.delete('conflict_')
class FileStoragePermissions(TestCase):
def setUp(self):
self.old_perms = settings.FILE_UPLOAD_PERMISSIONS
settings.FILE_UPLOAD_PERMISSIONS = 0666
def test_file_upload_permissions(self):
name = temp_storage.save("the_file", ContentFile("data"))
actual_mode = os.stat(temp_storage.path(name))[0] & 0777
self.assertEqual(actual_mode, 0666)
def tearDown(self):
settings.FILE_UPLOAD_PERMISSIONS = self.old_perms