allow user to ignore file warnings

This commit is contained in:
ccd0 2014-05-01 01:17:42 -07:00
parent fada31bb78
commit 5f0021842e

View File

@ -344,11 +344,21 @@ QR =
$.addClass QR.nodes.el, 'dump' unless files.length is 1 $.addClass QR.nodes.el, 'dump' unless files.length is 1
handleFile: (file, index, nfiles) -> handleFile: (file, index, nfiles) ->
if file.type in QR.mimeTypes if /^text\//.test file.type
if nfiles is 1
post = QR.selected
else if index isnt 0 or (post = QR.posts[QR.posts.length - 1]).com
post = new QR.post()
post.pasteText file
return
unless file.type in QR.mimeTypes
QR.error "#{file.name}: Unsupported file type."
return unless nfiles is 1
max = QR.nodes.fileInput.max max = QR.nodes.fileInput.max
max = Math.min(max, QR.max_size_video) if /^video\//.test file.type max = Math.min(max, QR.max_size_video) if /^video\//.test file.type
if file.size > max if file.size > max
return QR.error "#{file.name}: File too large (file: #{$.bytesToString file.size}, max: #{$.bytesToString max})." QR.error "#{file.name}: File too large (file: #{$.bytesToString file.size}, max: #{$.bytesToString max})."
return unless nfiles is 1
isNewPost = false isNewPost = false
if nfiles is 1 if nfiles is 1
post = QR.selected post = QR.selected
@ -356,18 +366,10 @@ QR =
isNewPost = true isNewPost = true
post = new QR.post() post = new QR.post()
QR.checkDimensions file, (pass) -> QR.checkDimensions file, (pass) ->
if pass if pass or nfiles is 1
post.setFile file post.setFile file
else if isNewPost else if isNewPost
post.rm() post.rm()
else if /^text/.test file.type
if nfiles is 1
post = QR.selected
else if index isnt 0 or (post = QR.posts[QR.posts.length - 1]).com
post = new QR.post()
post.pasteText file
else
QR.error "#{file.name}: Unsupported file type."
checkDimensions: (file, cb) -> checkDimensions: (file, cb) ->
if /^image\//.test file.type if /^image\//.test file.type
@ -407,6 +409,9 @@ QR =
cb = null cb = null
$.on video, 'error', => $.on video, 'error', =>
return unless cb? return unless cb?
if file.type in QR.mimeTypes
# only report error here if we should have been able to play the video
# otherwise "unsupported type" should already have been shown
QR.error "#{file.name}: Video appears corrupt" QR.error "#{file.name}: Video appears corrupt"
cb false cb false
cb = null cb = null