<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,6 +1,6 @@
 Gem::Specification.new do |s|
   s.name = &quot;has_image&quot;
-  s.version = &quot;0.1.6&quot;
+  s.version = &quot;0.1.7&quot;
   s.date = &quot;2008-08-01&quot;
   s.add_dependency('mini_magick', '&gt;= 1.2.3')
   s.rubyforge_project = 'has-image'  </diff>
      <filename>has_image.gemspec</filename>
    </modified>
    <modified>
      <diff>@@ -6,26 +6,31 @@ require 'zlib'
 module HasImage  
   
   # Filesystem storage for the HasImage gem. The methods that HasImage inserts
-  # into ActiveRecord models only depend on the public methods in this class, so
-  # it should be reasonably straightforward to implement a different storage
-  # mechanism for Amazon AWS, Photobucket, DBFile, SFTP, or whatever you want.  
+  # into ActiveRecord models only depend on the public methods in this class,
+  # so it should be reasonably straightforward to implement a different
+  # storage mechanism for Amazon AWS, Photobucket, DBFile, SFTP, or whatever
+  # you want.  
   class Storage
     
     attr_accessor :image_data, :options, :temp_file
 
     class &lt;&lt; self
       
-      # Stolen from {Jamis Buck}[http://www.37signals.com/svn/archives2/id_partitioning.php].
+      # {Jamis Buck's well known
+      # solution}[http://www.37signals.com/svn/archives2/id_partitioning.php]
+      # to this problem fails with high ids, such as those created by
+      # db:fixture:load. This version scales to large ids more gracefully.
+      # Thanks to Adrian Mugnolo for the fix.
       def partitioned_path(id, *args)
-        (&quot;%08d&quot; % id).scan(/..../) + args
+        [&quot;%04d&quot; % ((id.to_i / 1e4) % 1e4), &quot;%04d&quot; % (id.to_i % 1e4)].concat(args)
       end
 
-      # Generates a 4-6 character random file name to use for the image and its
-      # thumbnails. This is done to avoid having files with unfortunate names.
-      # On one of my sites users frequently upload images with Arabic names, and
-      # they end up being hard to manipulate on the command line. This also
-      # helps prevent a possibly undesirable sitation where the uploaded images
-      # have offensive names.
+      # Generates a 4-6 character random file name to use for the image and
+      # its thumbnails. This is done to avoid having files with unfortunate
+      # names. On one of my sites users frequently upload images with Arabic
+      # names, and they end up being hard to manipulate on the command line.
+      # This also helps prevent a possibly undesirable sitation where the
+      # uploaded images have offensive names.
       def random_file_name
         Zlib.crc32(Time.now.to_s + rand(10e10).to_s).to_s(36).downcase
       end</diff>
      <filename>lib/has_image/storage.rb</filename>
    </modified>
    <modified>
      <diff>@@ -20,6 +20,11 @@ class StorageTest &lt; Test::Unit::TestCase
     assert_equal([&quot;0001&quot;, &quot;2345&quot;], HasImage::Storage.partitioned_path(&quot;12345&quot;))
   end
   
+  def test_partitioned_path_doesnt_collide_with_high_ids
+    assert_not_equal HasImage::Storage.partitioned_path(867792732),
+      HasImage::Storage.partitioned_path(867792731)
+  end
+  
   def test_random_file_name
     assert_match(/[a-z0-9]{4,6}/i, HasImage::Storage.random_file_name)
   end</diff>
      <filename>test/storage_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>2dfa7ddbb73b9b34bb3172b640427cd1f929fd14</id>
    </parent>
    <parent>
      <id>bc10e72c80c78d3ff240a2eb7b5018594e74c5d0</id>
    </parent>
  </parents>
  <author>
    <name>Norman Clarke</name>
    <email>norman@addthree.com</email>
  </author>
  <url>http://github.com/norman/has_image/commit/bda419354f2cdd5ea331be2c45158fc502778e96</url>
  <id>bda419354f2cdd5ea331be2c45158fc502778e96</id>
  <committed-date>2008-08-18T08:37:50-07:00</committed-date>
  <authored-date>2008-08-18T08:37:50-07:00</authored-date>
  <message>Merge branch 'master' of git@github.com:norman/has_image

Conflicts:

	CHANGELOG
	has_image.gemspec</message>
  <tree>fced65bf772c9bd064918f42d83d2763ed56c44e</tree>
  <committer>
    <name>Norman Clarke</name>
    <email>norman@addthree.com</email>
  </committer>
</commit>
