From 7d6cb0405504a536a88aa8467e474f7fd13299a7 Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Fri, 30 Dec 2016 13:38:26 -0500 Subject: [PATCH] 10538: Clear up default_trash_interval logic --- services/api/app/models/collection.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/services/api/app/models/collection.rb b/services/api/app/models/collection.rb index 93d4620927..572a717567 100644 --- a/services/api/app/models/collection.rb +++ b/services/api/app/models/collection.rb @@ -454,10 +454,12 @@ class Collection < ArvadosModel # If trash_at is updated without touching delete_at, automatically # update delete_at to a sensible value. def default_trash_interval - if trash_at && trash_at_changed? && !delete_at_changed? - self.delete_at = trash_at + Rails.configuration.default_trash_lifetime.seconds - elsif trash_at.nil? && trash_at_changed? && !delete_at_changed? - self.delete_at = nil + if trash_at_changed? && !delete_at_changed? + if trash_at.nil? + self.delete_at = nil + else + self.delete_at = trash_at + Rails.configuration.default_trash_lifetime.seconds + end end end -- 2.30.2