diff --git a/app/models/post.rb b/app/models/post.rb index a218d49d791..485db2d7000 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -480,6 +480,16 @@ class Post < ActiveRecord::Base p.rebake! rescue => e problems << { post: p, ex: e } + + attempts = p.custom_fields["rebake_attempts"].to_i + if attempts > 3 + p.update_columns(baked_version: BAKED_VERSION) + Discourse.warn_exception(e, "Can not rebake post# #{p.id} after 3 attempts, giving up") + else + p.custom_fields["rebake_attempts"] = attempts + 1 + p.save_custom_fields + end + end end problems