[Rt-commit] rt branch, 4.4/improve-rt-externalize-attachments, created. rt-4.4.2-59-g21de1f9e4
Craig Kaiser
craig at bestpractical.com
Thu Jan 18 10:45:50 EST 2018
The branch, 4.4/improve-rt-externalize-attachments has been created
at 21de1f9e428f289e4cfd06125564d3363d7c899b (commit)
- Log -----------------------------------------------------------------
commit 21de1f9e428f289e4cfd06125564d3363d7c899b
Author: Craig Kaiser <craig at bestpractical.com>
Date: Tue Dec 26 14:09:44 2017 -0500
Improve rt-externalize-attachments
Support for 'attachment_id' flag to submit a start ID, where
attachments prior to the specified ID will not be externalized.
diff --git a/sbin/rt-externalize-attachments.in b/sbin/rt-externalize-attachments.in
index 18b251368..bffc0ef81 100644
--- a/sbin/rt-externalize-attachments.in
+++ b/sbin/rt-externalize-attachments.in
@@ -76,6 +76,7 @@ GetOptions( \%opts,
"age=s",
"batchsize=s",
"dry-run",
+ "attachment_id=s",
);
if ($opts{'help'}) {
@@ -116,6 +117,7 @@ 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 $attachment_id = $opts{'attachment_id'};
while (1) {
my $attach = $class->new($RT::SystemUser);
@@ -130,7 +132,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 +215,6 @@ for my $class (qw/RT::Attachments RT::ObjectCustomFieldValues/) {
RT->Logger->info("Stored $class $id as $key");
}
}
-
last unless $attach->Count and $batchsize > 0;
}
$last->{$class} = $id;
@@ -270,8 +278,14 @@ upload begins and after it completes.
Make a trial run and do no changes (mostly the same output as a real run is
produced). C<dry-run> implies verbose output.
+
+=item --attachment_id
+
+Provide a attachment ID to have as the starting point of the externalize.
+
=back
+
=head1 SEE ALSO
L<RT_Config.html/External-storage>, L<RT::ExternalStorage>
-----------------------------------------------------------------------
More information about the rt-commit
mailing list