[Rubygems-developers] [PATCH] Don't die when trying to load zero-byte gem files

Tilman Sauerbeck tilman at code-monkey.de
Wed Dec 28 11:57:00 EST 2005


Hi,
I tried to install a zero-byte gem file (I didn't notice the Rubyforge
download failed), which made rubygems crash.

Here's a fix.

Regards,
Tilman
-------------- next part --------------
Index: lib/rubygems/format.rb
===================================================================
RCS file: /var/cvs/rubygems/rubygems/lib/rubygems/format.rb,v
retrieving revision 1.10
diff -u -r1.10 format.rb
--- lib/rubygems/format.rb	12 Jun 2005 14:27:22 -0000	1.10
+++ lib/rubygems/format.rb	28 Dec 2005 16:42:23 -0000
@@ -27,7 +27,7 @@
     # file_path:: [String] Path to the gem file
     #
     def self.from_file_by_path(file_path, security_policy = nil)
-      unless File.exist?(file_path)
+      unless File.size(file_path) > 20
         raise Gem::Exception, "Cannot load gem at [#{file_path}]"
       end
       require 'fileutils'
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/rubygems-developers/attachments/20051228/3f43d093/attachment.bin


More information about the Rubygems-developers mailing list