X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Fsbin%2Frt-fulltext-indexer.in;h=ceffc97b8e39096eb5074f04ac4d60d325ddc8be;hb=d61cf1825f89216eebc83da5510c34b330b55abb;hp=bd55adb9a9ab9b249b6c1314d1c226aa77be60d2;hpb=1c538bfabc2cd31f27067505f0c3d1a46cba6ef0;p=freeside.git diff --git a/rt/sbin/rt-fulltext-indexer.in b/rt/sbin/rt-fulltext-indexer.in index bd55adb9a..ceffc97b8 100644 --- a/rt/sbin/rt-fulltext-indexer.in +++ b/rt/sbin/rt-fulltext-indexer.in @@ -3,7 +3,7 @@ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2016 Best Practical Solutions, LLC # # # (Except where explicitly superseded by other copyright notices) @@ -99,6 +99,8 @@ if ( !flock main::DATA, LOCK_EX | LOCK_NB ) { } } +my $max_size = RT->Config->Get('MaxFulltextAttachmentSize'); + my $db_type = RT->Config->Get('DatabaseType'); my $fts_config = $ENV{RT_FTS_CONFIG} ? JSON::from_json($ENV{RT_FTS_CONFIG}) : RT->Config->Get('FullTextSearch') || {}; @@ -201,8 +203,16 @@ sub process_bulk_insert { my ($attachments) = @_; my @insert; my $found = 0; + while ( my $a = $attachments->Next ) { debug("Found attachment #". $a->id ); + if ( $max_size and $a->ContentLength > $max_size ){ + debug("Attachment #" . $a->id . " is " . $a->ContentLength . + " bytes which is larger than configured MaxFulltextAttachmentSize " . + " of " . $max_size . ", skipping"); + next; + } + my $text = $a->Content // ""; HTML::Entities::decode_entities($text) if $a->ContentType eq "text/html"; push @insert, $text, $a->id; @@ -304,9 +314,17 @@ sub process_pg_update { attachment_loop( sub { my ($attachments) = @_; my @insert; + while ( my $a = $attachments->Next ) { debug("Found attachment #". $a->id ); + if ( $max_size and $a->ContentLength > $max_size ){ + debug("Attachment #" . $a->id . " is " . $a->ContentLength . + " bytes which is larger than configured MaxFulltextAttachmentSize " . + " of " . $max_size . ", skipping"); + next; + } + my $text = $a->Content // ""; HTML::Entities::decode_entities($text) if $a->ContentType eq "text/html";