<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,3 +1,8 @@
+2008-08-1 Norman Clarke &lt;norman@randomba.org&gt;
+  
+  * Fixed a bug where overwriting a previous image triggered callbacks more
+    than once, causing errors.
+
 2008-07-29 Norman Clarke &lt;norman@randomba.org&gt;
 
   * Downcased generated file names to avoid potential issues on</diff>
      <filename>CHANGELOG</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,7 @@
 Gem::Specification.new do |s|
   s.name = &quot;has_image&quot;
-  s.version = &quot;0.1.5&quot;
-  s.date = &quot;2008-07-29&quot;
+  s.version = &quot;0.1.6&quot;
+  s.date = &quot;2008-08-01&quot;
   s.add_dependency('mini_magick', '&gt;= 1.2.3')
   s.rubyforge_project = 'has-image'  
   s.summary = &quot;Lets you attach images with thumbnails to active record models.&quot;</diff>
      <filename>has_image.gemspec</filename>
    </modified>
    <modified>
      <diff>@@ -210,10 +210,17 @@ module HasImage
     # Deletes the image from the storage.
     def remove_images
       return if has_image_file.blank?
-      storage.remove_images(self.id)
-      update_attribute(:has_image_file, nil)
-    rescue Errno::ENOENT
-      logger.warn(&quot;Could not delete files for #{self.class.to_s} #{to_param}&quot;) 
+      self.class.transaction do
+        begin
+          # Resorting to SQL here to avoid triggering callbacks. There must be
+          # a better way to do this.
+          self.connection.execute(&quot;UPDATE #{self.class.table_name} SET has_image_file = NULL WHERE id = #{id}&quot;)
+          self.has_image_file = nil
+          storage.remove_images(self.id)
+        rescue Errno::ENOENT
+          logger.warn(&quot;Could not delete files for #{self.class.to_s} #{to_param}&quot;)
+        end
+      end
     end
     
     # Creates new images and removes the old ones when image_data has been</diff>
      <filename>lib/has_image.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>703760e4bbf15ffad3a4ce0a6670355482f6693c</id>
    </parent>
  </parents>
  <author>
    <name>Norman Clarke</name>
    <email>norman@addthree.com</email>
  </author>
  <url>http://github.com/norman/has_image/commit/52bfffe2cc0947400efe31f342689835967a19f5</url>
  <id>52bfffe2cc0947400efe31f342689835967a19f5</id>
  <committed-date>2008-08-01T08:26:44-07:00</committed-date>
  <authored-date>2008-08-01T08:26:44-07:00</authored-date>
  <message>Fixed a bug where overwriting a previous image triggered callbacks more than
once, causing errors.</message>
  <tree>d08dde25917161ee919d67341d1f721e7c2b2673</tree>
  <committer>
    <name>Norman Clarke</name>
    <email>norman@addthree.com</email>
  </committer>
</commit>
