mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
avoid work if nothing there
This commit is contained in:
parent
2d3a090060
commit
2625c3bb9a
1 changed files with 3 additions and 2 deletions
|
@ -4,6 +4,9 @@ class StylesheetCache < ActiveRecord::Base
|
||||||
MAX_TO_KEEP = 10
|
MAX_TO_KEEP = 10
|
||||||
|
|
||||||
def self.add(target,digest,content)
|
def self.add(target,digest,content)
|
||||||
|
|
||||||
|
return false if where(target: target, digest: digest).exists?
|
||||||
|
|
||||||
success = create(target: target, digest: digest, content: content)
|
success = create(target: target, digest: digest, content: content)
|
||||||
|
|
||||||
count = StylesheetCache.count
|
count = StylesheetCache.count
|
||||||
|
@ -20,8 +23,6 @@ class StylesheetCache < ActiveRecord::Base
|
||||||
success
|
success
|
||||||
rescue ActiveRecord::RecordNotUnique
|
rescue ActiveRecord::RecordNotUnique
|
||||||
false
|
false
|
||||||
rescue PG::UniqueViolation
|
|
||||||
false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue