avoid work if nothing there
This commit is contained in:
parent
2d3a090060
commit
2625c3bb9a
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue