Skip to content

Commit 39028b9

Browse files
fix(settings): replace DEFAULT_FILE_STORAGE with STORAGES[default]
1 parent 0ab677a commit 39028b9

16 files changed

Lines changed: 48 additions & 33 deletions

cms/envs/common.py

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

1304-
STATICFILES_STORAGE = 'openedx.core.storage.ProductionStorage'
13051304
STATICFILES_STORAGE_KWARGS = {}
13061305

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

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

25582564
###################### Grade Downloads ######################
25592565
# 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-
del DEFAULT_FILE_STORAGE
12+
STORAGES['default']['BACKEND'] = 'django.core.files.storage.FileSystemStorage'
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-
STATICFILES_STORAGE = 'openedx.core.storage.DevelopmentStorage'
59+
STORAGES['staticfiles']['BACKEND'] = '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-
STATICFILES_STORAGE = 'pipeline.storage.PipelineManifestStorage'
36+
STORAGES['staticfiles']['BACKEND'] = '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-
DEFAULT_FILE_STORAGE = AUTH_TOKENS.get('DEFAULT_FILE_STORAGE')
25+
STORAGES["default"]["BACKEND"] = AUTH_TOKENS.get('DEFAULT_FILE_STORAGE')
2626
elif SWIFT_AUTH_URL and SWIFT_USERNAME and SWIFT_KEY:
27-
DEFAULT_FILE_STORAGE = 'swift.storage.SwiftStorage'
27+
STORAGES["default"]["BACKEND"] = 'swift.storage.SwiftStorage'
2828
else:
29-
DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage'
29+
STORAGES["default"]["BACKEND"] = 'django.core.files.storage.FileSystemStorage'
3030

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

cms/envs/production.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ 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-
STATICFILES_STORAGE = os.environ.get('STATICFILES_STORAGE', STATICFILES_STORAGE)
225+
STORAGES['staticfiles']['BACKEND'] = os.environ.get(
226+
'STATICFILES_STORAGE', STORAGES['staticfiles']['BACKEND'])
226227
CSRF_TRUSTED_ORIGINS = _YAML_TOKENS.get("CSRF_TRUSTED_ORIGINS", [])
227228

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

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

270271
if COURSE_IMPORT_EXPORT_BUCKET:
271272
COURSE_IMPORT_EXPORT_STORAGE = 'cms.djangoapps.contentstore.storage.ImportExportS3Storage'
272273
else:
273-
COURSE_IMPORT_EXPORT_STORAGE = DEFAULT_FILE_STORAGE
274+
COURSE_IMPORT_EXPORT_STORAGE = STORAGES["default"]["BACKEND"]
274275

275276
USER_TASKS_ARTIFACT_STORAGE = COURSE_IMPORT_EXPORT_STORAGE
276277

277278
if COURSE_METADATA_EXPORT_BUCKET:
278279
COURSE_METADATA_EXPORT_STORAGE = 'cms.djangoapps.export_course_metadata.storage.CourseMetadataExportS3Storage'
279280
else:
280-
COURSE_METADATA_EXPORT_STORAGE = DEFAULT_FILE_STORAGE
281+
COURSE_METADATA_EXPORT_STORAGE = STORAGES["default"]["BACKEND"]
281282

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

cms/envs/test.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
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,
3332
ECOMMERCE_API_URL,
3433
ENABLE_COMPREHENSIVE_THEMING,
3534
JWT_AUTH,
@@ -91,7 +90,7 @@
9190
# If we don't add these settings, then Django templates that can't
9291
# find pipelined assets will raise a ValueError.
9392
# http://stackoverflow.com/questions/12816941/unit-testing-with-django-pipeline
94-
STATICFILES_STORAGE = "pipeline.storage.NonPackagingPipelineStorage"
93+
STORAGES['staticfiles']['BACKEND'] = "pipeline.storage.NonPackagingPipelineStorage"
9594
STATIC_URL = "/static/"
9695

9796
# Update module store settings per defaults for tests

cms/envs/test_static_optimized.py

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

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

3233
# Revert to the default set of finders as we don't want to dynamically pick up files from the pipeline
3334
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.DEFAULT_FILE_STORAGE == 'storages.backends.s3boto3.S3Boto3Storage':
81+
if is_private and settings.STORAGES["default"]["BACKEND"] == '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: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2356,7 +2356,6 @@ 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'
23602359
STATICFILES_STORAGE_KWARGS = {}
23612360

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

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

52095215
### Proctoring configuration (redirct URLs and keys shared between systems) ####
52105216
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-
del DEFAULT_FILE_STORAGE
19+
STORAGES['default']['BACKEND'] = 'django.core.files.storage.FileSystemStorage'
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-
STATICFILES_STORAGE = 'openedx.core.storage.DevelopmentStorage'
122+
STORAGES['staticfiles']['BACKEND'] = '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)