Permalink
Browse files

Restructure saving to deal with s3 errors better

  • Loading branch information...
1 parent 82b3dc2 commit f2542bcdf90f6ed5536189b983c3d2f594c0dc32 @evanphx evanphx committed Jun 11, 2014
Showing with 13 additions and 4 deletions.
  1. +13 −4 app/models/pusher.rb
View
17 app/models/pusher.rb
@@ -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 f2542bc

Please sign in to comment.