Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
edx-platform
Commits
2f98f8af
Commit
2f98f8af
authored
Sep 11, 2017
by
Jillian Vogel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use django storage mechanism to determine file size
when serving course export tarball.
parent
76d3b62b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
3 deletions
+7
-3
cms/djangoapps/contentstore/views/import_export.py
+4
-3
cms/envs/openstack.py
+3
-0
No files found.
cms/djangoapps/contentstore/views/import_export.py
View file @
2f98f8af
...
@@ -270,14 +270,14 @@ def import_status_handler(request, course_key_string, filename=None):
...
@@ -270,14 +270,14 @@ def import_status_handler(request, course_key_string, filename=None):
return
JsonResponse
({
"ImportStatus"
:
status
})
return
JsonResponse
({
"ImportStatus"
:
status
})
def
send_tarball
(
tarball
):
def
send_tarball
(
tarball
,
size
):
"""
"""
Renders a tarball to response, for use when sending a tar.gz file to the user.
Renders a tarball to response, for use when sending a tar.gz file to the user.
"""
"""
wrapper
=
FileWrapper
(
tarball
)
wrapper
=
FileWrapper
(
tarball
)
response
=
HttpResponse
(
wrapper
,
content_type
=
'application/x-tgz'
)
response
=
HttpResponse
(
wrapper
,
content_type
=
'application/x-tgz'
)
response
[
'Content-Disposition'
]
=
'attachment; filename=
%
s'
%
os
.
path
.
basename
(
tarball
.
name
.
encode
(
'utf-8'
))
response
[
'Content-Disposition'
]
=
'attachment; filename=
%
s'
%
os
.
path
.
basename
(
tarball
.
name
.
encode
(
'utf-8'
))
response
[
'Content-Length'
]
=
os
.
path
.
getsize
(
tarball
.
name
)
response
[
'Content-Length'
]
=
size
return
response
return
response
...
@@ -381,6 +381,7 @@ def export_status_handler(request, course_key_string):
...
@@ -381,6 +381,7 @@ def export_status_handler(request, course_key_string):
else
:
else
:
# local file, serve from the authorization wrapper view
# local file, serve from the authorization wrapper view
output_url
=
reverse_course_url
(
'export_output_handler'
,
course_key
)
output_url
=
reverse_course_url
(
'export_output_handler'
,
course_key
)
elif
task_status
.
state
in
(
UserTaskStatus
.
FAILED
,
UserTaskStatus
.
CANCELED
):
elif
task_status
.
state
in
(
UserTaskStatus
.
FAILED
,
UserTaskStatus
.
CANCELED
):
status
=
max
(
-
(
task_status
.
completed_steps
+
1
),
-
2
)
status
=
max
(
-
(
task_status
.
completed_steps
+
1
),
-
2
)
errors
=
UserTaskArtifact
.
objects
.
filter
(
status
=
task_status
,
name
=
'Error'
)
errors
=
UserTaskArtifact
.
objects
.
filter
(
status
=
task_status
,
name
=
'Error'
)
...
@@ -423,7 +424,7 @@ def export_output_handler(request, course_key_string):
...
@@ -423,7 +424,7 @@ def export_output_handler(request, course_key_string):
try
:
try
:
artifact
=
UserTaskArtifact
.
objects
.
get
(
status
=
task_status
,
name
=
'Output'
)
artifact
=
UserTaskArtifact
.
objects
.
get
(
status
=
task_status
,
name
=
'Output'
)
tarball
=
course_import_export_storage
.
open
(
artifact
.
file
.
name
)
tarball
=
course_import_export_storage
.
open
(
artifact
.
file
.
name
)
return
send_tarball
(
tarball
)
return
send_tarball
(
tarball
,
artifact
.
file
.
storage
.
size
(
artifact
.
file
.
name
)
)
except
UserTaskArtifact
.
DoesNotExist
:
except
UserTaskArtifact
.
DoesNotExist
:
raise
Http404
raise
Http404
finally
:
finally
:
...
...
cms/envs/openstack.py
View file @
2f98f8af
...
@@ -27,3 +27,6 @@ elif SWIFT_AUTH_URL and SWIFT_USERNAME and SWIFT_KEY:
...
@@ -27,3 +27,6 @@ elif SWIFT_AUTH_URL and SWIFT_USERNAME and SWIFT_KEY:
DEFAULT_FILE_STORAGE
=
'swift.storage.SwiftStorage'
DEFAULT_FILE_STORAGE
=
'swift.storage.SwiftStorage'
else
:
else
:
DEFAULT_FILE_STORAGE
=
'django.core.files.storage.FileSystemStorage'
DEFAULT_FILE_STORAGE
=
'django.core.files.storage.FileSystemStorage'
# Use default file storage class set above for course import/export
COURSE_IMPORT_EXPORT_STORAGE
=
DEFAULT_FILE_STORAGE
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment