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
edx
edx-platform
Commits
2f98f8af
Commit
2f98f8af
authored
Sep 11, 2017
by
Jillian Vogel
1
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
Show 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):
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.
"""
wrapper
=
FileWrapper
(
tarball
)
response
=
HttpResponse
(
wrapper
,
content_type
=
'application/x-tgz'
)
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
...
...
@@ -381,6 +381,7 @@ def export_status_handler(request, course_key_string):
else
:
# local file, serve from the authorization wrapper view
output_url
=
reverse_course_url
(
'export_output_handler'
,
course_key
)
elif
task_status
.
state
in
(
UserTaskStatus
.
FAILED
,
UserTaskStatus
.
CANCELED
):
status
=
max
(
-
(
task_status
.
completed_steps
+
1
),
-
2
)
errors
=
UserTaskArtifact
.
objects
.
filter
(
status
=
task_status
,
name
=
'Error'
)
...
...
@@ -423,7 +424,7 @@ def export_output_handler(request, course_key_string):
try
:
artifact
=
UserTaskArtifact
.
objects
.
get
(
status
=
task_status
,
name
=
'Output'
)
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
:
raise
Http404
finally
:
...
...
cms/envs/openstack.py
View file @
2f98f8af
...
...
@@ -27,3 +27,6 @@ elif SWIFT_AUTH_URL and SWIFT_USERNAME and SWIFT_KEY:
DEFAULT_FILE_STORAGE
=
'swift.storage.SwiftStorage'
else
:
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
XuYS
@xys
mentioned in commit
5c8b310a
Dec 21, 2017
mentioned in commit
5c8b310a
mentioned in commit 5c8b310a228941c50cd57a677c5dc5b5fb6ff7ed
Toggle commit list
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