From c94b63bc756ff8468087d7be7f4b423da1d445e5 Mon Sep 17 00:00:00 2001 From: Gerhard Schlager Date: Thu, 26 Mar 2020 16:33:38 +0100 Subject: [PATCH] DEV: Improve import of attachments from Telligent --- script/import_scripts/telligent.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/script/import_scripts/telligent.rb b/script/import_scripts/telligent.rb index 0e166523cdb..d9b364fb155 100644 --- a/script/import_scripts/telligent.rb +++ b/script/import_scripts/telligent.rb @@ -42,8 +42,13 @@ class ImportScripts::Telligent < ImportScripts::Base BATCH_SIZE ||= 1000 LOCAL_AVATAR_REGEX ||= /\A~\/.*(?communityserver-components-(?:selectable)?avatars)\/(?[^\/]+)\/(?.+)/i REMOTE_AVATAR_REGEX ||= /\Ahttps?:\/\//i - EMBEDDED_ATTACHMENT_REGEX ||= /.*?<\/a>/i - EMBEDDED_VIEW_ATTACHMENT_REGEX ||= /\[View:~\/cfs-file(?:\.ashx)?\/__key\/(?[^\/]+)\/(?[^\/]+)\/(?.+?)(?:\:[:\d\s]*?)\]/i + ATTACHMENT_REGEXES ||= [ + /]*\shref="[^"]*?\/cfs-file(?:systemfile)?(?:\.ashx)?\/__key\/(?[^\/]+)\/(?[^\/]+)\/(?.+?)".*?>.*?<\/a>/i, + /]*\ssrc="[^"]*?\/cfs-file(?:systemfile)?(?:\.ashx)?\/__key\/(?[^\/]+)\/(?[^\/]+)\/(?.+?)".*?>/i, + /\[View:[^\]]*?\/cfs-file(?:systemfile)?(?:\.ashx)?\/__key\/(?[^\/]+)\/(?[^\/]+)\/(?.+?)(?:\:[:\d\s]*?)?\]/i, + /\[(?img|url)\][^\[]*?cfs-file(?:systemfile)?(?:\.ashx)?\/__key\/(?[^\/]+)\/(?[^\/]+)\/(?.+?)\[\/\k\]/i, + /\[(?img|url)=[^\[]*?cfs-file(?:systemfile)?(?:\.ashx)?\/__key\/(?[^\/]+)\/(?[^\/]+)\/(?.+?)\][^\[]*?\[\/\k\]/i + ] PROPERTY_NAMES_REGEX ||= /(?\w+):S:(?\d+):(?\d+):/ CATEGORY_LINK_NORMALIZATION = '/.*?(f\/\d+)$/\1' @@ -560,7 +565,7 @@ class ImportScripts::Telligent < ImportScripts::Base return [raw, paths, upload_ids] if @filestore_root_directory.blank? - [EMBEDDED_ATTACHMENT_REGEX, EMBEDDED_VIEW_ATTACHMENT_REGEX].each do |regex| + ATTACHMENT_REGEXES.each do |regex| raw = raw.gsub(regex) do match_data = Regexp.last_match @@ -579,6 +584,7 @@ class ImportScripts::Telligent < ImportScripts::Base else path = File.join(path, match_data[:filename]) STDERR.puts "Could not find file: #{path}" + match_data[0] end end end