From a3e6216dbc2ef072b4e3017aa8596f182fa213ec Mon Sep 17 00:00:00 2001
From: Arnaud Levy <contact@arnaudlevy.com>
Date: Mon, 5 Dec 2022 15:41:13 +0100
Subject: [PATCH] better

---
 app/models/concerns/with_permalink.rb | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/app/models/concerns/with_permalink.rb b/app/models/concerns/with_permalink.rb
index 37fa6d0bf..d9a06e5ec 100644
--- a/app/models/concerns/with_permalink.rb
+++ b/app/models/concerns/with_permalink.rb
@@ -24,9 +24,8 @@ module WithPermalink
 
     # If the object had no permalink or if its path changed, we create a new permalink
     if new_permalink.computed_path.present? && (last_permalink.nil? || last_permalink.path != new_permalink.computed_path)
-      last_permalink&.update(is_current: false)
       new_permalink.path = new_permalink.computed_path
-      new_permalink.save
+      last_permalink&.update(is_current: false) if new_permalink.save
     end
   end
 
-- 
GitLab