[Rt-commit] rt branch, 4.4/improve-rt-externalize-attachments, created. rt-4.4.2-59-gc499a87f7
Craig Kaiser
craig at bestpractical.com
Thu Jan 11 08:54:19 EST 2018
The branch, 4.4/improve-rt-externalize-attachments has been created
at c499a87f7ebfd6939311cdfb60577e64f857b79e (commit)
- Log -----------------------------------------------------------------
commit c499a87f7ebfd6939311cdfb60577e64f857b79e
Author: Craig Kaiser <craig at bestpractical.com>
Date: Tue Dec 26 14:09:44 2017 -0500
Improve rt-externalize-attachments
Support for 'attachments' flag that allows the number of attachments that will be
processed to be specified. Add 'attachment_id' flag to submit a start ID, where
attachments prior to the specified ID will be limited.
diff --git a/sbin/rt-externalize-attachments.in b/sbin/rt-externalize-attachments.in
index 18b251368..05b085f90 100644
--- a/sbin/rt-externalize-attachments.in
+++ b/sbin/rt-externalize-attachments.in
@@ -76,6 +76,8 @@ GetOptions( \%opts,
"age=s",
"batchsize=s",
"dry-run",
+ "attachments=s",
+ "attachment_id=s",
);
if ($opts{'help'}) {
@@ -116,6 +118,8 @@ for my $class (qw/RT::Attachments RT::ObjectCustomFieldValues/) {
my $column = $class eq 'RT::Attachments' ? "Content" : "LargeContent";
my $id = $last->{$class} || 0;
my $batchsize = $opts{'batchsize'} || 1;
+ my $attachments = $opts{'attachments'} || 9999;
+ my $attachment_id = $opts{'attachment_id'};
while (1) {
my $attach = $class->new($RT::SystemUser);
@@ -130,7 +134,14 @@ for my $class (qw/RT::Attachments RT::ObjectCustomFieldValues/) {
VALUE => 'external',
ENTRYAGGREGATOR => 'AND',
);
-
+ if ($opts{'attachment_id'}) {
+ $attach->Limit(
+ FIELD => 'ID',
+ OPERATOR => '>=',
+ VALUE => $attachment_id,
+ ENTRYAGGREGATOR => 'AND',
+ );
+ }
if ($opts{'age'}) {
my $agelimit = strftime "%F", localtime(time()-$opts{'age'}*24*60*60);
$attach->Limit(
@@ -206,7 +217,11 @@ for my $class (qw/RT::Attachments RT::ObjectCustomFieldValues/) {
RT->Logger->info("Stored $class $id as $key");
}
}
-
+ if ( $attach->Count >= $attachments && $attachments ) {
+ RT->Logger->info("Reached attachment limit.");
+ exit 2;
+ }
+ }
last unless $attach->Count and $batchsize > 0;
}
$last->{$class} = $id;
@@ -271,6 +286,21 @@ Make a trial run and do no changes (mostly the same output as a real run is
produced). C<dry-run> implies verbose output.
=back
+=item --attachments
+
+Provide the number of attachments you would like to process.
+
+=item --attachments
+
+Provide the number of attachments you would like to process.
+
+=item --attachment_id
+
+Provide a attachment ID to have as the starting point of the externalize.
+
+=item --attachment_id
+
+Provide a attachment ID to have as the starting point of the externalize.
=head1 SEE ALSO
-----------------------------------------------------------------------
More information about the rt-commit
mailing list