Permalink
Browse files

Restructure saving to deal with s3 errors better

  • Loading branch information...
evanphx committed Jun 11, 2014
1 parent c55c09a commit 87312bcfa5b1b5cef932caae0c90f2cfe9d4e4a2
Showing with 13 additions and 4 deletions.
  1. +13 −4 app/models/pusher.rb
View
@@ -25,12 +25,21 @@ def authorize
end
def save
- if update
+ # Restructured so that if we fail to write the gem (ie, s3 is down)
+ # can clean things up well.
+
+ begin
@indexer.write_gem @body, @spec
- after_write
- notify("Successfully registered gem: #{version.to_title}", 200)
+ rescue StandardError => e
+ @version.destroy
+ notify("There was a problem saving your gem: #{e}", 403)
else
- notify("There was a problem saving your gem: #{rubygem.all_errors(version)}", 403)
+ if update
+ after_write
+ notify("Successfully registered gem: #{version.to_title}", 200)
+ else
+ notify("There was a problem saving your gem: #{rubygem.all_errors(version)}", 403)
+ end
end
end

0 comments on commit 87312bc

Please sign in to comment.