Commit 2904bdab authored by ale's avatar ale

* increase polling frequency for async upload to give better feedback

* fix ticket #19
parent 57909890
......@@ -202,12 +202,12 @@ class VideoController(BaseController):
if 'token' in request.params:
async_http = True
token = request.params.get('token')
try:
upload = model.AsyncUpload.query.get(token)
file_size = upload.size
local_file_path = upload.path()
except:
upload = model.AsyncUpload.query.filter_by(token=token).first()
if not upload:
log.error("Could not retrieve async upload %s" % token)
abort(404)
file_size = upload.size
local_file_path = upload.path()
else:
async_http = False
post_file = request.POST['file']
......@@ -260,8 +260,8 @@ class VideoController(BaseController):
video_id=video.video_id)
video.modify()
model.Session.save_or_update(file)
model.Session.update(video)
model.Session.add(file)
model.Session.add(video)
model.Session.commit()
# schedule new 'original' videos for processing
......@@ -272,7 +272,7 @@ class VideoController(BaseController):
file.schedule_job(g.jobserver, action='incoming',
group='incoming',
local_file_path=job_file_path)
model.Session.update(file)
model.Session.add(file)
model.Session.commit()
# since the file was copied somewhere, we can now safely
......@@ -303,7 +303,7 @@ class VideoController(BaseController):
video = self._get_video(id)
file = model.File.query.get(request.params['f'])
file.schedule_job(g.jobserver, action=action, group=group)
model.Session.update(file)
model.Session.add(file)
model.Session.commit()
return 'OK'
......@@ -335,7 +335,7 @@ class VideoController(BaseController):
author=h.logged_author(),
text=self.form_result.get('text'))
video.comments.append(cmt)
model.Session.save(cmt)
model.Session.add(cmt)
model.Session.commit()
redirect_to(action='comments')
......@@ -352,6 +352,6 @@ class VideoController(BaseController):
model.Audit.log('Review of %s (%d) from %s' % (
video.title, video.video_id, h.logged_author().username))
video.set_status(model.Video.Status.REVIEW)
model.Session.save(cmt)
model.Session.add(cmt)
model.Session.commit()
redirect_to(action='reviews')
......@@ -24,7 +24,10 @@ prettySize = function(sz) {
// Show progress made so far
showProgress = function(cur, tot) {
var pct = Math.round(cur * 100 / tot);
var pct = 0;
if (tot > 0) {
pct = Math.round(cur * 100 / tot);
}
$('#progressTxt').html(prettySize(cur) + ' of ' + prettySize(tot) + ' (<strong>' + pct + '%</strong>)');
$('#progressBar').css('width', pct + '%');
};
......@@ -44,8 +47,6 @@ pingHandler = function(stat, cur, tot) {
}
debug('Upload complete!');
showProgress(tot, tot);
// Fill out final form, and submit it!
$('#newFileFormToken').attr("value", token);
$('#newFileForm').submit();
return false;
}
......@@ -80,13 +81,15 @@ getToken = function() {
url: url,
success: function(token) {
debug('received token: ' + token);
// Now, submit the form
// Save the token in the final form
$('#newFileFormToken').attr("value", token);
// Now, submit the upload form
action = $('#uploadForm').attr('action');
action += '/' + token;
$('#uploadForm').attr('action', action);
debug('submitting form to ' + action);
$('#uploadForm').submit();
$.timer(5000, getUploadPoller(token));
$.timer(1000, getUploadPoller(token));
},
error: function(){
error('Could not communicate with the upload server (no upload token)');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment