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
fcd11d93
Commit
fcd11d93
authored
Aug 22, 2013
by
Julian Arni
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle nginx 499s and double requests
parent
8a8bcf28
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
3 deletions
+19
-3
cms/djangoapps/contentstore/views/import_export.py
+7
-3
cms/static/sass/views/_import.scss
+5
-0
cms/templates/import.html
+7
-0
No files found.
cms/djangoapps/contentstore/views/import_export.py
View file @
fcd11d93
...
...
@@ -89,16 +89,20 @@ def import_course(request, org, course, name):
# 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'
]):
if
size
<
int
(
content_range
[
'start'
]):
log
.
warning
(
"Reported range
%
s does not match size downloaded so far
%
s"
,
size
,
content_range
[
'start'
]
content_range
[
'start'
]
,
size
)
return
JsonResponse
(
{
'ErrMsg'
:
'File upload corrupted. Please try again'
},
status
=
409
)
# The last request sometimes comes twice. This happens because
# nginx sends a 499 error code when the response takes too long.
elif
size
>
int
(
content_range
[
'stop'
])
and
size
==
int
(
content_range
[
'end'
]):
return
JsonResponse
({
'ImportStatus'
:
1
})
with
open
(
temp_filepath
,
mode
)
as
temp_file
:
for
chunk
in
request
.
FILES
[
'course-data'
]
.
chunks
():
...
...
cms/static/sass/views/_import.scss
View file @
fcd11d93
...
...
@@ -57,6 +57,11 @@ body.course.import {
color
:
$error-red
;
}
.status-block
{
display
:
none
;
font-size
:
13px
;
}
.choose-file-button
{
@include
blue-button
;
padding
:
10px
50px
11px
;
...
...
cms/templates/import.html
View file @
fcd11d93
...
...
@@ -34,6 +34,7 @@
<input
type=
"file"
name=
"course-data"
class=
"file-input"
>
<input
type=
"submit"
value=
"${_('Replace my course with the one above')}"
class=
"submit-button"
>
<input
type=
"hidden"
name=
"csrfmiddlewaretoken"
value=
"${csrf_token}"
>
<p
class=
"status-block"
>
Unpacking...
</p>
<div
class=
"progress-bar"
>
<div
class=
"progress-fill"
></div>
<div
class=
"percent"
>
0%
</div>
...
...
@@ -55,6 +56,7 @@ var bar = $('.progress-bar');
var
fill
=
$
(
'.progress-fill'
);
var
percent
=
$
(
'.percent'
);
var
status
=
$
(
'#status'
);
var
statusBlock
=
$
(
'.status-block'
);
var
submitBtn
=
$
(
'.submit-button'
);
...
...
@@ -79,6 +81,11 @@ $('#fileupload').fileupload({
alert
(
'${_("Your import has failed.")}
\
n
\
n'
+
JSON
.
parse
(
result
.
responseText
)[
"ErrMsg"
]);
submitBtn
.
show
();
bar
.
hide
();
}
else
{
if
(
result
.
responseText
[
"ImportStatus"
]
==
1
)
{
bar
.
hide
();
statusBlock
.
show
();
}
}
});
});
...
...
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