From 04bca84117116ec09d38c5902954799ee06a016c Mon Sep 17 00:00:00 2001 From: saint Date: Thu, 27 Jun 2024 15:32:05 +1000 Subject: [PATCH] v0.16.4 Profile image handling improvement --- gossamer_forums.rb | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/gossamer_forums.rb b/gossamer_forums.rb index 6003eb3..7f0a93c 100644 --- a/gossamer_forums.rb +++ b/gossamer_forums.rb @@ -1,5 +1,5 @@ # gossamer threads migration-import code -# v0.16.3 +# v0.16.4 require 'mysql2' require 'open-uri' @@ -501,11 +501,14 @@ class GossamerForumsImporter < ImportScripts::Base puts "#E" - # Append the image to the user's bio - user.user_profile.bio_raw ||= "" - user.user_profile.bio_raw += "\n\n![#{file['File_Name']}](#{file_url})" - user.user_profile.save! - + # Append the image to the user's bio_raw only if it does not already exist + image_markdown = "\n\n![#{file['File_Name']}](#{file_url})" + user.user_profile.bio_raw ||= "" + unless user.user_profile.bio_raw.include?(image_markdown) + user.user_profile.bio_raw += image_markdown + user.user_profile.save! + end + # Clean up temporary files temp_file.close temp_file.unlink