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
7666aad0
Commit
7666aad0
authored
Aug 15, 2013
by
Julian Arni
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check download integrity
parent
513b6cab
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
2 deletions
+17
-2
cms/djangoapps/contentstore/views/assets.py
+17
-2
No files found.
cms/djangoapps/contentstore/views/assets.py
View file @
7666aad0
...
...
@@ -298,7 +298,7 @@ def import_course(request, org, course, name):
try
:
matches
=
CONTENT_RE
.
search
(
request
.
META
[
"HTTP_CONTENT_RANGE"
])
content_range
=
matches
.
groupdict
()
except
KeyError
:
except
KeyError
:
# Single chunk - no Content-Range header
content_range
=
{
'start'
:
0
,
'stop'
:
9
,
'end'
:
10
}
# stream out the uploaded files in chunks to disk
...
...
@@ -306,6 +306,21 @@ def import_course(request, org, course, name):
mode
=
"wb+"
else
:
mode
=
"ab+"
size
=
os
.
path
.
getsize
(
temp_filepath
)
# Check to make sure we haven't missed a chunk
# This shouldn't happen, even if different instances are handling
# the same session, but it's always better to catch errors earlier.
if
size
!=
int
(
content_range
[
'start'
]):
log
.
warning
(
"Reported range
%
s does not match size downloaded so far
%
s"
,
size
,
content_range
[
'start'
]
)
return
JsonResponse
(
{
'ErrMsg'
:
'File upload corrupted. Please try again'
},
status
=
409
)
with
open
(
temp_filepath
,
mode
)
as
temp_file
:
for
chunk
in
request
.
FILES
[
'course-data'
]
.
chunks
():
...
...
@@ -347,7 +362,7 @@ def import_course(request, org, course, name):
# find the 'course.xml' file
dirpath
=
None
coursexmls
=
((
d
,
f
)
for
d
,
_
,
f
in
os
.
walk
(
course_dir
)
coursexmls
=
((
d
,
f
)
for
d
,
_
,
f
in
os
.
walk
(
course_dir
)
if
f
.
count
(
'course.xml'
)
>
0
)
try
:
...
...
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