[Rt-commit] rt branch, 4.4/external-storage, updated. rt-4.2.11-32-g0672f48

Shawn Moore shawn at bestpractical.com
Thu May 21 19:33:22 EDT 2015


The branch, 4.4/external-storage has been updated
       via  0672f483cc73023fdb6fd897519c0192354261b8 (commit)
      from  55b3d178e0e3e0da0afc62a0d66671abb07743d8 (commit)

Summary of changes:
 etc/RT_Config.pm.in                | 16 ++++++++++++++++
 lib/RT/Attachment.pm               |  4 ++--
 lib/RT/ObjectCustomFieldValue.pm   |  2 +-
 sbin/rt-externalize-attachments.in |  2 +-
 4 files changed, 20 insertions(+), 4 deletions(-)

- Log -----------------------------------------------------------------
commit 0672f483cc73023fdb6fd897519c0192354261b8
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Thu May 21 23:32:49 2015 +0000

    New config for ExternalStorageCutoffSize
    
        (Honestly, mostly because I want to test with much smaller files)

diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index c341ccd..30de2d7 100644
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -2557,6 +2557,22 @@ and accepts.
 
 Set(%ExternalStorage, ());
 
+=item C<$ExternalStorageCutoffSize>
+
+Certain object types, like values for Binary custom fields, are always
+put into external storage. However, for other object types, like images
+and text, there is a line in the sand where you want small objects in the
+database but large objects in external storage. By default, objects larger
+than 10 MiB (10*1024*1024 bytes) will be put into external storage.
+C<$ExternalStorageCutoffSize> adjusts that line in the sand.
+
+Note that changing this setting does not affect existing attachments, only
+the new ones that C<sbin/rt-externalize-attachments> hasn't seen yet.
+
+=cut
+
+Set($ExternalStorageCutoffSize, 10*1024*1024);
+
 =back
 
 =head1 Lifecycles
diff --git a/lib/RT/Attachment.pm b/lib/RT/Attachment.pm
index 9570447..195d60d 100644
--- a/lib/RT/Attachment.pm
+++ b/lib/RT/Attachment.pm
@@ -1189,11 +1189,11 @@ sub ShouldStoreExternally {
         return 0;
     } elsif ($type =~ m{^(text|message)/}) {
         # If textual, we only store externally if it's _large_ (> 10M)
-        return 1 if $length > 10 * 1024 * 1024;
+        return 1 if $length > RT->Config->Get('ExternalStorageCutoffSize');
         return 0;
     } elsif ($type =~ m{^image/}) {
         # Ditto images, which may be displayed inline
-        return 1 if $length > 10 * 1024 * 1024;
+        return 1 if $length > RT->Config->Get('ExternalStorageCutoffSize');
         return 0;
     } else {
         return 1;
diff --git a/lib/RT/ObjectCustomFieldValue.pm b/lib/RT/ObjectCustomFieldValue.pm
index 66a096d..963b795 100644
--- a/lib/RT/ObjectCustomFieldValue.pm
+++ b/lib/RT/ObjectCustomFieldValue.pm
@@ -742,7 +742,7 @@ sub ShouldStoreExternally {
 
     return 1 if $type eq "Binary";
 
-    return 1 if $type eq "Image" and $length > 10 * 1024 * 1024;
+    return 1 if $type eq "Image" and $length > RT->Config->Get('ExternalStorageCutoffSize');
 
     return 0;
 }
diff --git a/sbin/rt-externalize-attachments.in b/sbin/rt-externalize-attachments.in
index 90344b4..b5e87cf 100755
--- a/sbin/rt-externalize-attachments.in
+++ b/sbin/rt-externalize-attachments.in
@@ -111,7 +111,7 @@ for my $class (qw/RT::Attachments RT::ObjectCustomFieldValues/) {
             $attach->Limit(
                 FUNCTION  => 'LENGTH(main.Content)',
                 OPERATOR  => '>',
-                VALUE     => 10*1024*1024,
+                VALUE     => RT->Config->Get('ExternalStorageCutoffSize'),
                 SUBCLAUSE => 'applies',
                 ENTRYAGGREGATOR => 'OR',
             );

-----------------------------------------------------------------------


More information about the rt-commit mailing list