Commit 454b5ca5 by Jon Yurek

Close all the files! Well, some anyway.

parent 726f183c
...@@ -2,14 +2,9 @@ source "https://rubygems.org" ...@@ -2,14 +2,9 @@ source "https://rubygems.org"
gemspec gemspec
platform :jruby do gem "jruby-openssl", :platform=>:jruby
gem 'jruby-openssl' gem "activerecord-jdbcsqlite3-adapter", :platform=>:jruby
gem 'activerecord-jdbcsqlite3-adapter' gem 'pry', :platform=>:ruby
end gem 'pry-debugger', :platform=>:ruby
platform :ruby do
gem 'pry'
gem 'pry-debugger'
end
gem "cocaine", :path => "/Users/jyurek/Development/cocaine" gem "cocaine", :path => "/Users/jyurek/Development/cocaine"
...@@ -429,10 +429,16 @@ module Paperclip ...@@ -429,10 +429,16 @@ module Paperclip
def post_process_style(name, style) #:nodoc: def post_process_style(name, style) #:nodoc:
begin begin
raise RuntimeError.new("Style #{name} has no processors defined.") if style.processors.blank? raise RuntimeError.new("Style #{name} has no processors defined.") if style.processors.blank?
original_file = @queued_for_write[:original]
@queued_for_write[name] = style.processors.inject(@queued_for_write[:original]) do |file, processor| @queued_for_write[name] = style.processors.inject(@queued_for_write[:original]) do |file, processor|
Paperclip.processor(processor).make(file, style.processor_options, self) new_file = Paperclip.processor(processor).make(file, style.processor_options, self)
file.close unless file == original_file
new_file
end end
unadapted_file = @queued_for_write[name]
@queued_for_write[name] = Paperclip.io_adapters.for(@queued_for_write[name]) @queued_for_write[name] = Paperclip.io_adapters.for(@queued_for_write[name])
unadapted_file.close if unadapted_file.respond_to?(:close)
@queued_for_write[name]
rescue Paperclip::Error => e rescue Paperclip::Error => e
log("An error was received while processing: #{e.inspect}") log("An error was received while processing: #{e.inspect}")
(@errors[:processing] ||= []) << e.message if @options[:whiny] (@errors[:processing] ||= []) << e.message if @options[:whiny]
......
...@@ -643,7 +643,7 @@ class AttachmentTest < Test::Unit::TestCase ...@@ -643,7 +643,7 @@ class AttachmentTest < Test::Unit::TestCase
rebuild_model :processors => [:thumbnail, :test], :styles => @style_params rebuild_model :processors => [:thumbnail, :test], :styles => @style_params
@dummy = Dummy.new @dummy = Dummy.new
@file = StringIO.new("...") @file = StringIO.new("...")
@file.stubs(:to_tempfile).returns(@file) @file.stubs(:close)
Paperclip::Test.stubs(:make).returns(@file) Paperclip::Test.stubs(:make).returns(@file)
Paperclip::Thumbnail.stubs(:make).returns(@file) Paperclip::Thumbnail.stubs(:make).returns(@file)
end end
......
...@@ -44,7 +44,7 @@ class Test::Unit::TestCase ...@@ -44,7 +44,7 @@ class Test::Unit::TestCase
end end
def teardown def teardown
report_files # report_file:
end end
def report_files def report_files
...@@ -231,3 +231,35 @@ def assert_frame_dimensions(range, frames) ...@@ -231,3 +231,35 @@ def assert_frame_dimensions(range, frames)
end end
end end
end end
# class File
# def initialize_with_logging(*args)
# if args.first != "/Users/jyurek/.pry_history"
# pp "NEW FILE #{args.inspect}"
# # pp caller
# end
# initialize_without_logging(*args)
# end
# alias_method :initialize_without_logging, :initialize
# alias_method :initialize, :initialize_with_logging
#
# def close_with_logging(*args)
# if path != "/Users/jyurek/.pry_history"
# pp "CLOSE FILE #{self.path}"
# # pp caller
# end
# close_without_logging(*args)
# end
# alias_method :close_without_logging, :close
# alias_method :close, :close_with_logging
# end
#
# class Tempfile
# def initialize_with_logging(*args)
# # pp "NEW #{args.inspect}"
# # pp caller
# initialize_without_logging(*args)
# end
# alias_method :initialize_without_logging, :initialize
# alias_method :initialize, :initialize_with_logging
# end
require './test/helper' require './test/helper'
require 'pp'
# class File
# def initialize_with_logging(*args)
# p "NEW FILE #{args.inspect}"
# p caller
# initialize_without_logging(*args)
# end
# alias_method :initialize_without_logging, :initialize
# alias_method :initialize, :initialize_with_logging
# end
# class Tempfile
# def initialize_with_logging(*args)
# p "NEW #{args.inspect}"
# initialize_without_logging(*args)
# end
# alias_method :initialize_without_logging, :initialize
# alias_method :initialize, :initialize_with_logging
# end
class AttachmentAdapterTest < Test::Unit::TestCase class AttachmentAdapterTest < Test::Unit::TestCase
def setup def setup
...@@ -37,6 +20,7 @@ class AttachmentAdapterTest < Test::Unit::TestCase ...@@ -37,6 +20,7 @@ class AttachmentAdapterTest < Test::Unit::TestCase
teardown do teardown do
@file.close @file.close
@subject.close
end end
should "get the right filename" do should "get the right filename" do
...@@ -116,6 +100,7 @@ class AttachmentAdapterTest < Test::Unit::TestCase ...@@ -116,6 +100,7 @@ class AttachmentAdapterTest < Test::Unit::TestCase
teardown do teardown do
@file.close @file.close
@thumb.close @thumb.close
@subject.close
end end
should "get the original filename" do should "get the original filename" do
......
...@@ -2,12 +2,6 @@ require './test/helper' ...@@ -2,12 +2,6 @@ require './test/helper'
class EmptyStringAdapterTest < Test::Unit::TestCase class EmptyStringAdapterTest < Test::Unit::TestCase
def teardown
if @subject
@subject.close
end
end
context 'a new instance' do context 'a new instance' do
setup do setup do
@subject = Paperclip.io_adapters.for('') @subject = Paperclip.io_adapters.for('')
......
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