avoid work if nothing there

This commit is contained in:
Sam 2015-05-06 07:12:38 +10:00
parent 2d3a090060
commit 2625c3bb9a
1 changed files with 3 additions and 2 deletions

View File

@ -4,6 +4,9 @@ class StylesheetCache < ActiveRecord::Base
MAX_TO_KEEP = 10
def self.add(target,digest,content)
return false if where(target: target, digest: digest).exists?
success = create(target: target, digest: digest, content: content)
count = StylesheetCache.count
@ -20,8 +23,6 @@ class StylesheetCache < ActiveRecord::Base
success
rescue ActiveRecord::RecordNotUnique
false
rescue PG::UniqueViolation
false
end
end