don't fail zipping empty folders. fixes #5002
Change-Id: I510facebfc85fd617013741d862d3417b66ce341 Reviewed-on: https://gerrit.instructure.com/4949 Reviewed-by: Brian Palmer <brianp@instructure.com> Tested-by: Hudson <hudson@instructure.com>
This commit is contained in:
parent
aa69f2bc02
commit
828a58b9e3
|
@ -225,7 +225,7 @@ class ContentZipper
|
|||
end
|
||||
|
||||
def zip_base_folder(zip_attachment, folder)
|
||||
@files_added = false
|
||||
@files_added = true
|
||||
@logger.debug("zipping into attachment: #{zip_attachment.id}")
|
||||
zip_attachment.workflow_state = 'zipping' #!(:workflow_state => 'zipping')
|
||||
zip_attachment.scribd_attempts += 1
|
||||
|
@ -285,9 +285,7 @@ class ContentZipper
|
|||
@context = folder.context
|
||||
@logger.debug(" found attachment: #{attachment.unencoded_filename}")
|
||||
path = folder_names.empty? ? attachment.filename : File.join(folder_names, attachment.unencoded_filename)
|
||||
if add_attachment_to_zip(attachment, zipfile, path)
|
||||
@files_added = true
|
||||
end
|
||||
@files_added = false unless add_attachment_to_zip(attachment, zipfile, path)
|
||||
end
|
||||
folder.active_sub_folders.select{|f| !@user || f.grants_right?(@user, nil, :read_contents)}.each do |sub_folder|
|
||||
new_names = Array.new(folder_names) << sub_folder.name
|
||||
|
|
|
@ -47,5 +47,17 @@ describe ContentZipper do
|
|||
end
|
||||
names.sort.should == ['visible.png', 'visible/sub-vis.png']
|
||||
end
|
||||
|
||||
it "should not error on empty folders" do
|
||||
course_with_student(:active_all => true)
|
||||
folder = Folder.root_folders(@course).first
|
||||
attachment = Attachment.new(:display_name => 'my_download.zip')
|
||||
attachment.user_id = @user.id
|
||||
attachment.workflow_state = 'to_be_zipped'
|
||||
attachment.context = folder
|
||||
attachment.save!
|
||||
ContentZipper.process_attachment(attachment, @user)
|
||||
attachment.workflow_state.should == 'zipped'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue