[Rt-commit] rt branch, 4.4/improve-rt-externalize-attachments, created. rt-4.4.2-59-g3927c7d
Craig Kaiser
craig at bestpractical.com
Fri Jan 5 13:42:26 EST 2018
The branch, 4.4/improve-rt-externalize-attachments has been created
at 3927c7d383795980786a9a842950a4673d416b8b (commit)
- Log -----------------------------------------------------------------
commit 3927c7d383795980786a9a842950a4673d416b8b
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 18b2513..d9c667b 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 ) {
+ 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