fix race condition generating submissions zip
fixes CNVS-6283 test plan: * use S3 files * download a submissions zip for an assignment (the larger the resultant zip the more likely to hit the race condition) * it should only zip up the files once Change-Id: I01920e726d9cfff429a5b23440da1f6794ee9d14 Reviewed-on: https://gerrit.instructure.com/21385 Reviewed-by: Brian Palmer <brianp@instructure.com> Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Jacob Fugal <jacob@instructure.com> QA-Review: Jeremy Putnam <jeremyp@instructure.com> Product-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
parent
e64be3d55b
commit
fb1165f500
|
@ -150,7 +150,7 @@ class EportfoliosController < ApplicationController
|
|||
zip_filename = "eportfolio.zip"
|
||||
@portfolio = Eportfolio.find(params[:eportfolio_id])
|
||||
if authorized_action(@portfolio, @current_user, :update)
|
||||
@attachments = @portfolio.attachments.find_all_by_display_name(zip_filename).select{|a| ['to_be_zipped', 'zipping', 'zipped'].include?(a.workflow_state) }.sort_by{|a| a.created_at }
|
||||
@attachments = @portfolio.attachments.find_all_by_display_name(zip_filename).select{|a| ['to_be_zipped', 'zipping', 'zipped', 'unattached'].include?(a.workflow_state) }.sort_by{|a| a.created_at }
|
||||
@attachment = @attachments.pop
|
||||
@attachments.each{|a| a.destroy! }
|
||||
if @attachment && (@attachment.created_at < 1.hour.ago || @attachment.created_at < (@portfolio.eportfolio_entries.map{|s| s.updated_at}.compact.max || @attachment.created_at))
|
||||
|
|
|
@ -157,7 +157,7 @@ class FoldersController < ApplicationController
|
|||
folder_filename = "#{t :folder_filename, "folder"}.zip"
|
||||
|
||||
@attachments = Attachment.find_all_by_context_id_and_context_type_and_display_name_and_user_id(@folder.id, @folder.class.to_s, folder_filename, user_id).
|
||||
select{|a| ['to_be_zipped', 'zipping', 'zipped'].include?(a.workflow_state) && !a.deleted? }.
|
||||
select{|a| ['to_be_zipped', 'zipping', 'zipped', 'unattached'].include?(a.workflow_state) && !a.deleted? }.
|
||||
sort_by{|a| a.created_at }
|
||||
@attachment = @attachments.pop
|
||||
@attachments.each{|a| a.destroy! }
|
||||
|
|
|
@ -172,7 +172,7 @@ class QuizSubmissionsController < ApplicationController
|
|||
# TODO: this is mostly copied and pasted from submission_controller.rb. pull
|
||||
# out common code
|
||||
def submission_zip
|
||||
@attachments = @quiz.attachments.where(:display_name => 'submissions.zip', :workflow_state => ['to_be_zipped', 'zipping', 'zipped', 'errored'], :user_id => @current_user).order(:created_at).all
|
||||
@attachments = @quiz.attachments.where(:display_name => 'submissions.zip', :workflow_state => ['to_be_zipped', 'zipping', 'zipped', 'errored', 'unattached'], :user_id => @current_user).order(:created_at).all
|
||||
@attachment = @attachments.pop
|
||||
@attachments.each{|a| a.destroy! }
|
||||
if @attachment && (@attachment.created_at < 1.hour.ago || @attachment.created_at < (@quiz.quiz_submissions.map{|s| s.finished_at}.compact.max || @attachment.created_at))
|
||||
|
|
|
@ -514,7 +514,7 @@ class SubmissionsController < ApplicationController
|
|||
protected
|
||||
|
||||
def submission_zip
|
||||
@attachments = @assignment.attachments.where(:display_name => 'submissions.zip', :workflow_state => ['to_be_zipped', 'zipping', 'zipped', 'errored'], :user_id => @current_user).order(:created_at).all
|
||||
@attachments = @assignment.attachments.where(:display_name => 'submissions.zip', :workflow_state => ['to_be_zipped', 'zipping', 'zipped', 'errored', 'unattached'], :user_id => @current_user).order(:created_at).all
|
||||
@attachment = @attachments.pop
|
||||
@attachments.each{|a| a.destroy! }
|
||||
if @attachment && (@attachment.created_at < 1.hour.ago || @attachment.created_at < (@assignment.submissions.map{|s| s.submitted_at}.compact.max || @attachment.created_at))
|
||||
|
|
Loading…
Reference in New Issue