From d3c748a74d6c2befe133dcfe5c909e25fe29c70e Mon Sep 17 00:00:00 2001 From: Sebastian Ludwig Date: Thu, 23 May 2013 15:36:17 +0200 Subject: [PATCH 1/2] Fixed exception when getting the properties of IO objects twice (by rewinding when done) --- lib/fastimage.rb | 2 ++ test/test.rb | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/lib/fastimage.rb b/lib/fastimage.rb index b73adfc..c6bbfd1 100644 --- a/lib/fastimage.rb +++ b/lib/fastimage.rb @@ -173,6 +173,8 @@ class FastImage end end + uri.rewind if uri.respond_to?(:rewind) + raise SizeNotFound if options[:raise_on_failure] && @property == :size && !@size rescue Timeout::Error, SocketError, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Errno::ECONNRESET, diff --git a/test/test.rb b/test/test.rb index 63be5f3..4c50211 100644 --- a/test/test.rb +++ b/test/test.rb @@ -123,6 +123,15 @@ class FastImageTest < Test::Unit::TestCase end end end + + def test_should_report_size_correctly_on_io_object_twice + GoodFixtures.each do |fn, info| + File.open(File.join(FixturePath, fn), "r") do |io| + assert_equal info[1], FastImage.size(io) + assert_equal info[1], FastImage.size(io) + end + end + end def test_should_report_size_correctly_for_local_files_with_path_that_has_spaces Dir.chdir(PathHere) do From 8d30fb6af972065bc0b68fb0c0025c727c5efa93 Mon Sep 17 00:00:00 2001 From: Stephen Sykes Date: Sat, 29 Jun 2013 17:09:33 +0300 Subject: [PATCH 2/2] Update dates on license --- MIT-LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MIT-LICENSE b/MIT-LICENSE index 3e479cc..24a670f 100644 --- a/MIT-LICENSE +++ b/MIT-LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2008-2011 Stephen Sykes +Copyright (c) 2008-2013 Stephen Sykes Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the