From 2625c3bb9a445f8a59817dfc40230d1c4310d5e7 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 6 May 2015 07:12:38 +1000 Subject: [PATCH] avoid work if nothing there --- app/models/stylesheet_cache.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/models/stylesheet_cache.rb b/app/models/stylesheet_cache.rb index c123e8aadf9..152db2484a9 100644 --- a/app/models/stylesheet_cache.rb +++ b/app/models/stylesheet_cache.rb @@ -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