From ffb67cd3a84daa7af2d4f15739502851b65b5a49 Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Fri, 16 Jun 2017 23:04:52 -0700 Subject: [PATCH] site archiving: update timestamp when ipfs hash already exists --- models/site.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/models/site.rb b/models/site.rb index 74cf4f38..54c6d842 100644 --- a/models/site.rb +++ b/models/site.rb @@ -732,7 +732,12 @@ class Site < Sequel::Model archive.updated_at = Time.now archive.save_changes else - add_archive ipfs_hash: ipfs_hash, updated_at: Time.now + begin + add_archive ipfs_hash: ipfs_hash, updated_at: Time.now + rescue Sequel::UniqueConstraintViolation + # Record already exists, update timestamp + archives_dataset.where(ipfs_hash: ipfs_hash).first.update updated_at: Time.now + end end end