[Rt-commit] rt branch, 4.4/externalstorage-backend-key, created. rt-4.4.1-112-gec09ad3
Shawn Moore
shawn at bestpractical.com
Wed Sep 21 11:20:55 EDT 2016
The branch, 4.4/externalstorage-backend-key has been created
at ec09ad3568a86adcd64c571488761ebaed98caf3 (commit)
- Log -----------------------------------------------------------------
commit ec09ad3568a86adcd64c571488761ebaed98caf3
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Thu Sep 15 16:29:54 2016 -0400
Store backend-specific keys in the attachment
This enables storage engines to store/retrieve files by methods other than
SHA256 of content
See rt-extension-externalstorage e6b72fc85c9b070e02c74458c5470871b70012e1
diff --git a/lib/RT/ExternalStorage/AmazonS3.pm b/lib/RT/ExternalStorage/AmazonS3.pm
index 1ded7a1..5f9bca0 100644
--- a/lib/RT/ExternalStorage/AmazonS3.pm
+++ b/lib/RT/ExternalStorage/AmazonS3.pm
@@ -144,13 +144,13 @@ sub Store {
my ($sha, $content) = @_;
# No-op if the path exists already
- return (1) if $self->BucketObj->head_key( $sha );
+ return ($sha) if $self->BucketObj->head_key( $sha );
$self->BucketObj->add_key(
$sha => $content
) or return (undef, "Failed to write to AmazonS3: " . $self->S3->errstr);
- return (1);
+ return ($sha);
}
sub DownloadURLFor {
diff --git a/lib/RT/ExternalStorage/Disk.pm b/lib/RT/ExternalStorage/Disk.pm
index 60046fe..3a78c47 100644
--- a/lib/RT/ExternalStorage/Disk.pm
+++ b/lib/RT/ExternalStorage/Disk.pm
@@ -111,7 +111,7 @@ sub Store {
my $dir = $self->Path . "/$1/$2";
my $path = "$dir/$3";
- return (1) if -f $path;
+ return ($sha) if -f $path;
File::Path::make_path($dir, {error => \my $err});
return (undef, "Making directory failed") if @{$err};
@@ -120,7 +120,7 @@ sub Store {
print $fh $content or return (undef, "Cannot write file to disk: $!");
close $fh or return (undef, "Cannot write file to disk: $!");
- return (1);
+ return ($sha);
}
sub DownloadURLFor {
diff --git a/lib/RT/ExternalStorage/Dropbox.pm b/lib/RT/ExternalStorage/Dropbox.pm
index 58aeea4..29d243c 100644
--- a/lib/RT/ExternalStorage/Dropbox.pm
+++ b/lib/RT/ExternalStorage/Dropbox.pm
@@ -124,7 +124,7 @@ sub Store {
my $dropbox = $self->Dropbox;
# No-op if the path exists already. This forces a metadata read.
- return (1) if open( $dropbox, "<", $sha);
+ return ($sha) if open( $dropbox, "<", $sha);
open( $dropbox, ">", $sha )
or return (undef, "Open for write on dropbox failed: $!");
@@ -133,7 +133,7 @@ sub Store {
close $dropbox
or return (undef, "Flush to dropbox failed: $!");
- return (1);
+ return ($sha);
}
sub DownloadURLFor {
diff --git a/sbin/rt-externalize-attachments.in b/sbin/rt-externalize-attachments.in
index 9782347..b085a17 100644
--- a/sbin/rt-externalize-attachments.in
+++ b/sbin/rt-externalize-attachments.in
@@ -189,11 +189,8 @@ RT->System->SetAttribute( Name => "ExternalStorage", Content => $last );
sub Store {
my $content = shift;
- my $key = Digest::SHA::sha256_hex( $content );
- my ($ok, $msg) = $ExternalStorage->Store( $key => $content );
- return ($ok, $msg) unless defined $ok;
-
- return ($key);
+ my $sha = Digest::SHA::sha256_hex( $content );
+ return $ExternalStorage->Store( $sha => $content );
}
=head1 NAME
-----------------------------------------------------------------------
More information about the rt-commit
mailing list