ruby 1.9: don't choke on course import with '~' filename
work around the issue where creating a temp file whose basename starts with '~' fails on ruby 1.9 ruby issue: https://bugs.ruby-lang.org/issues/7547 test plan: try to import the course linked in the ticket fixes #CNVS-2922 Change-Id: Iafbbae05c90dbef22e73e6311379e3aeee0a5f32 Reviewed-on: https://gerrit.instructure.com/16796 Tested-by: Jenkins <jenkins@instructure.com> QA-Review: Adam Phillipps <adam@instructure.com> Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
This commit is contained in:
parent
7b2f365419
commit
255e9d94b1
|
@ -110,7 +110,8 @@ class UnzipAttachment
|
|||
# Hyphenate the path. So, /some/file/path becomes some-file-path
|
||||
# Since Tempfile guarantees that the names are unique, we don't
|
||||
# have to worry about what this name actually is.
|
||||
Tempfile.open(filename) do |f|
|
||||
# NOTE: strip leading ~ as workaround for https://bugs.ruby-lang.org/issues/7547
|
||||
Tempfile.open(filename.sub(/^~/, '')) do |f|
|
||||
begin
|
||||
entry.extract(f.path) { true }
|
||||
# This is where the attachment actually happens. See file_in_context.rb
|
||||
|
|
Binary file not shown.
|
@ -131,6 +131,13 @@ describe UnzipAttachment do
|
|||
end
|
||||
end
|
||||
|
||||
it "should not fall over when facing a filename starting with ~" do
|
||||
filename = fixture_filename('tilde.zip')
|
||||
ua = UnzipAttachment.new(:course => @course, :filename => filename)
|
||||
lambda { ua.process }.should_not raise_error
|
||||
@course.attachments.map(&:display_name).should == ['~tilde']
|
||||
end
|
||||
|
||||
describe 'validations' do
|
||||
|
||||
let(:filename) { fixture_filename('huge_zip.zip') }
|
||||
|
|
Loading…
Reference in New Issue