Skip to content

Commit f4c3575

Browse files
authored
Revert "fix(settings): replace DEFAULT_FILE_STORAGE with STORAGES[default]" (#36907)
This reverts commit 39028b9.
1 parent 39028b9 commit f4c3575

16 files changed

Lines changed: 33 additions & 48 deletions

cms/envs/common.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,6 +1301,7 @@
13011301
'YUI_BINARY': 'yui-compressor',
13021302
}
13031303

1304+
STATICFILES_STORAGE = 'openedx.core.storage.ProductionStorage'
13041305
STATICFILES_STORAGE_KWARGS = {}
13051306

13061307
# List of finder classes that know how to find static files in various locations.
@@ -2552,14 +2553,7 @@
25522553
BULK_EMAIL_LOG_SENT_EMAILS = False
25532554

25542555
############### Settings for django file storage ##################
2555-
STORAGES = {
2556-
"default": {
2557-
"BACKEND": 'django.core.files.storage.FileSystemStorage'
2558-
},
2559-
"staticfiles": {
2560-
"BACKEND": 'openedx.core.storage.ProductionStorage',
2561-
}
2562-
}
2556+
DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage'
25632557

25642558
###################### Grade Downloads ######################
25652559
# These keys are used for all of our asynchronous downloadable files, including

cms/envs/devstack.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from .production import * # pylint: disable=wildcard-import, unused-wildcard-import
1010

1111
# Don't use S3 in devstack, fall back to filesystem
12-
STORAGES['default']['BACKEND'] = 'django.core.files.storage.FileSystemStorage'
12+
del DEFAULT_FILE_STORAGE
1313
COURSE_IMPORT_EXPORT_STORAGE = 'django.core.files.storage.FileSystemStorage'
1414
USER_TASKS_ARTIFACT_STORAGE = COURSE_IMPORT_EXPORT_STORAGE
1515

@@ -56,7 +56,7 @@
5656

5757
# Skip packaging and optimization in development
5858
PIPELINE['PIPELINE_ENABLED'] = False
59-
STORAGES['staticfiles']['BACKEND'] = 'openedx.core.storage.DevelopmentStorage'
59+
STATICFILES_STORAGE = 'openedx.core.storage.DevelopmentStorage'
6060

6161
# Revert to the default set of finders as we don't want the production pipeline
6262
STATICFILES_FINDERS = [

cms/envs/devstack_optimized.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
REQUIRE_DEBUG = False
3434

3535
# Fetch static files out of the pipeline's static root
36-
STORAGES['staticfiles']['BACKEND'] = 'pipeline.storage.PipelineManifestStorage'
36+
STATICFILES_STORAGE = 'pipeline.storage.PipelineManifestStorage'
3737

3838
# Serve static files at /static directly from the staticfiles directory under test root.
3939
# Note: optimized files for testing are generated with settings from test_static_optimized

cms/envs/openstack.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
SWIFT_EXTRA_OPTIONS = {'region_name': AUTH_TOKENS['SWIFT_REGION_NAME']}
2323

2424
if AUTH_TOKENS.get('DEFAULT_FILE_STORAGE'):
25-
STORAGES["default"]["BACKEND"] = AUTH_TOKENS.get('DEFAULT_FILE_STORAGE')
25+
DEFAULT_FILE_STORAGE = AUTH_TOKENS.get('DEFAULT_FILE_STORAGE')
2626
elif SWIFT_AUTH_URL and SWIFT_USERNAME and SWIFT_KEY:
27-
STORAGES["default"]["BACKEND"] = 'swift.storage.SwiftStorage'
27+
DEFAULT_FILE_STORAGE = 'swift.storage.SwiftStorage'
2828
else:
29-
STORAGES["default"]["BACKEND"] = 'django.core.files.storage.FileSystemStorage'
29+
DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage'
3030

3131
# Use default file storage class set above for course import/export
32-
COURSE_IMPORT_EXPORT_STORAGE = STORAGES["default"]["BACKEND"]
32+
COURSE_IMPORT_EXPORT_STORAGE = DEFAULT_FILE_STORAGE

cms/envs/production.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,7 @@ def get_env_setting(setting):
222222
# we need to run asset collection twice, once for local disk and once for S3.
223223
# Once we have migrated to service assets off S3, then we can convert this back to
224224
# managed by the yaml file contents
225-
STORAGES['staticfiles']['BACKEND'] = os.environ.get(
226-
'STATICFILES_STORAGE', STORAGES['staticfiles']['BACKEND'])
225+
STATICFILES_STORAGE = os.environ.get('STATICFILES_STORAGE', STATICFILES_STORAGE)
227226
CSRF_TRUSTED_ORIGINS = _YAML_TOKENS.get("CSRF_TRUSTED_ORIGINS", [])
228227

229228
MKTG_URL_LINK_MAP.update(_YAML_TOKENS.get('MKTG_URL_LINK_MAP', {}))
@@ -266,19 +265,19 @@ def get_env_setting(setting):
266265

267266
# Change to S3Boto3 if we haven't specified another default storage AND we have specified AWS creds.
268267
if (not _YAML_TOKENS.get('DEFAULT_FILE_STORAGE')) and AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY:
269-
STORAGES["default"]["BACKEND"] = 'storages.backends.s3boto3.S3Boto3Storage'
268+
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
270269

271270
if COURSE_IMPORT_EXPORT_BUCKET:
272271
COURSE_IMPORT_EXPORT_STORAGE = 'cms.djangoapps.contentstore.storage.ImportExportS3Storage'
273272
else:
274-
COURSE_IMPORT_EXPORT_STORAGE = STORAGES["default"]["BACKEND"]
273+
COURSE_IMPORT_EXPORT_STORAGE = DEFAULT_FILE_STORAGE
275274

276275
USER_TASKS_ARTIFACT_STORAGE = COURSE_IMPORT_EXPORT_STORAGE
277276

278277
if COURSE_METADATA_EXPORT_BUCKET:
279278
COURSE_METADATA_EXPORT_STORAGE = 'cms.djangoapps.export_course_metadata.storage.CourseMetadataExportS3Storage'
280279
else:
281-
COURSE_METADATA_EXPORT_STORAGE = STORAGES["default"]["BACKEND"]
280+
COURSE_METADATA_EXPORT_STORAGE = DEFAULT_FILE_STORAGE
282281

283282
# The normal database user does not have enough permissions to run migrations.
284283
# Migrations are run with separate credentials, given as DB_MIGRATION_*

cms/envs/test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from lms.envs.test import ( # pylint: disable=wrong-import-order, disable=unused-import
3030
ACCOUNT_MICROFRONTEND_URL,
3131
COMPREHENSIVE_THEME_DIRS, # unimport:skip
32+
DEFAULT_FILE_STORAGE,
3233
ECOMMERCE_API_URL,
3334
ENABLE_COMPREHENSIVE_THEMING,
3435
JWT_AUTH,
@@ -90,7 +91,7 @@
9091
# If we don't add these settings, then Django templates that can't
9192
# find pipelined assets will raise a ValueError.
9293
# http://stackoverflow.com/questions/12816941/unit-testing-with-django-pipeline
93-
STORAGES['staticfiles']['BACKEND'] = "pipeline.storage.NonPackagingPipelineStorage"
94+
STATICFILES_STORAGE = "pipeline.storage.NonPackagingPipelineStorage"
9495
STATIC_URL = "/static/"
9596

9697
# Update module store settings per defaults for tests

cms/envs/test_static_optimized.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
# Use RequireJS optimized storage
3030
STATICFILES_STORAGE = f"{OptimizedCachedRequireJsStorage.__module__}.{OptimizedCachedRequireJsStorage.__name__}"
31-
STORAGES['staticfiles']['BACKEND'] = STATICFILES_STORAGE
3231

3332
# Revert to the default set of finders as we don't want to dynamically pick up files from the pipeline
3433
STATICFILES_FINDERS = [

common/djangoapps/util/file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def store_uploaded_file(
7878
file_storage = DefaultStorage()
7979
# If a file already exists with the supplied name, file_storage will make the filename unique.
8080
stored_file_name = file_storage.save(stored_file_name, uploaded_file)
81-
if is_private and settings.STORAGES["default"]["BACKEND"] == 'storages.backends.s3boto3.S3Boto3Storage':
81+
if is_private and settings.DEFAULT_FILE_STORAGE == 'storages.backends.s3boto3.S3Boto3Storage':
8282
S3Boto3Storage().connection.meta.client.put_object_acl(
8383
ACL='private',
8484
Bucket=settings.AWS_STORAGE_BUCKET_NAME,

lms/envs/common.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2356,6 +2356,7 @@ def _make_locale_paths(settings): # pylint: disable=missing-function-docstring
23562356
'UGLIFYJS_BINARY': 'node_modules/.bin/uglifyjs',
23572357
}
23582358

2359+
STATICFILES_STORAGE = 'openedx.core.storage.ProductionStorage'
23592360
STATICFILES_STORAGE_KWARGS = {}
23602361

23612362
# List of finder classes that know how to find static files in various locations.
@@ -5203,14 +5204,7 @@ def _make_locale_paths(settings): # pylint: disable=missing-function-docstring
52035204
}
52045205

52055206
############### Settings for django file storage ##################
5206-
STORAGES = {
5207-
"default": {
5208-
"BACKEND": 'django.core.files.storage.FileSystemStorage'
5209-
},
5210-
"staticfiles": {
5211-
"BACKEND": 'openedx.core.storage.ProductionStorage'
5212-
}
5213-
}
5207+
DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage'
52145208

52155209
### Proctoring configuration (redirct URLs and keys shared between systems) ####
52165210
PROCTORING_BACKENDS = {

lms/envs/devstack.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from .production import * # pylint: disable=wildcard-import, unused-wildcard-import
1717

1818
# Don't use S3 in devstack, fall back to filesystem
19-
STORAGES['default']['BACKEND'] = 'django.core.files.storage.FileSystemStorage'
19+
del DEFAULT_FILE_STORAGE
2020
ORA2_FILEUPLOAD_BACKEND = 'django'
2121

2222

@@ -119,7 +119,7 @@ def should_show_debug_toolbar(request): # lint-amnesty, pylint: disable=missing
119119
########################### PIPELINE #################################
120120

121121
PIPELINE['PIPELINE_ENABLED'] = False
122-
STORAGES['staticfiles']['BACKEND'] = 'openedx.core.storage.DevelopmentStorage'
122+
STATICFILES_STORAGE = 'openedx.core.storage.DevelopmentStorage'
123123

124124
# Revert to the default set of finders as we don't want the production pipeline
125125
STATICFILES_FINDERS = [

0 commit comments

Comments
 (0)