[Rt-commit] rt branch, 4.4/externalstorage-backend-key, created. rt-4.4.1-278-g488e36c
Shawn Moore
shawn at bestpractical.com
Wed Jan 25 15:46:24 EST 2017
The branch, 4.4/externalstorage-backend-key has been created
at 488e36c5025946ceebbc8f657daa1e590f989dda (commit)
- Log -----------------------------------------------------------------
commit 488e36c5025946ceebbc8f657daa1e590f989dda
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 e9024a3..7964ef4 100644
--- a/lib/RT/ExternalStorage/AmazonS3.pm
+++ b/lib/RT/ExternalStorage/AmazonS3.pm
@@ -147,7 +147,7 @@ sub Store {
my ($sha, $content, $attachment) = @_;
# No-op if the path exists already
- return (1) if $self->BucketObj->head_key( $sha );
+ return ($sha) if $self->BucketObj->head_key( $sha );
# Without content_type, S3 can guess wrong and cause attachments downloaded
# via a link to have a content type of binary/octet-stream
@@ -156,7 +156,7 @@ sub Store {
{ content_type => $attachment->ContentType }
) 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 09421c4..fa8754b 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 bb153e9..15c31f7 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 4d164df..38e50ea 100644
--- a/sbin/rt-externalize-attachments.in
+++ b/sbin/rt-externalize-attachments.in
@@ -190,11 +190,8 @@ sub Store {
my $content = shift;
my $attachment = shift;
- my $key = Digest::SHA::sha256_hex( $content );
- my ($ok, $msg) = $ExternalStorage->Store( $key => $content, $attachment );
- return ($ok, $msg) unless defined $ok;
-
- return ($key);
+ my $sha = Digest::SHA::sha256_hex( $content );
+ return $ExternalStorage->Store( $sha => $content, $attachment );
}
=head1 NAME
-----------------------------------------------------------------------
More information about the rt-commit
mailing list