[Bps-public-commit] rt-extension-externalstorage branch, master, updated. 0.61-1-ge6b72fc

Shawn Moore shawn at bestpractical.com
Thu Sep 15 16:31:40 EDT 2016


The branch, master has been updated
       via  e6b72fc85c9b070e02c74458c5470871b70012e1 (commit)
      from  a9df4596ba43cd64552a2c9f3173e82bd0690b78 (commit)

Summary of changes:
 lib/RT/Extension/ExternalStorage.pm          | 7 +++----
 lib/RT/Extension/ExternalStorage/AmazonS3.pm | 4 ++--
 lib/RT/Extension/ExternalStorage/Disk.pm     | 4 ++--
 lib/RT/Extension/ExternalStorage/Dropbox.pm  | 4 ++--
 4 files changed, 9 insertions(+), 10 deletions(-)

- Log -----------------------------------------------------------------
commit e6b72fc85c9b070e02c74458c5470871b70012e1
Author: Dave Goehrig <dave at bestpractical.com>
Date:   Fri Sep 9 13:26:33 2016 -0400

    Store backend-specific keys in the attachment
    
    This enables storage engines to store/retrieve files by methods other than
    SHA256 of content

diff --git a/lib/RT/Extension/ExternalStorage.pm b/lib/RT/Extension/ExternalStorage.pm
index cfac2d8..096d758 100644
--- a/lib/RT/Extension/ExternalStorage.pm
+++ b/lib/RT/Extension/ExternalStorage.pm
@@ -180,10 +180,9 @@ sub Store {
     my $class = shift;
     my $content = shift;
 
-    my $key = Digest::SHA::sha256_hex( $content );
-    my ($ok, $msg) = $BACKEND->Store( $key => $content );
-    return ($ok, $msg) unless defined $ok;
-
+    my $sha = Digest::SHA::sha256_hex( $content );
+    my ($key, $msg) = $BACKEND->Store( $sha => $content );
+    return ($key, $msg) unless defined $key;
     return ($key);
 }
 
diff --git a/lib/RT/Extension/ExternalStorage/AmazonS3.pm b/lib/RT/Extension/ExternalStorage/AmazonS3.pm
index 773ab4d..3bec29f 100644
--- a/lib/RT/Extension/ExternalStorage/AmazonS3.pm
+++ b/lib/RT/Extension/ExternalStorage/AmazonS3.pm
@@ -115,13 +115,13 @@ sub Store {
     my ($sha, $content) = @_;
 
     # No-op if the path exists already
-    return (1) if $S3->bucket($self->{Bucket})->head_key( $sha );
+    return ($sha) if $S3->bucket($self->{Bucket})->head_key( $sha );
 
     $S3->bucket($self->{Bucket})->add_key(
         $sha => $content
     ) or return (undef, "Failed to write to AmazonS3: " . $S3->errstr);
 
-    return (1);
+    return ($sha);
 }
 
 =head1 NAME
diff --git a/lib/RT/Extension/ExternalStorage/Disk.pm b/lib/RT/Extension/ExternalStorage/Disk.pm
index e93fb84..abfe7f4 100644
--- a/lib/RT/Extension/ExternalStorage/Disk.pm
+++ b/lib/RT/Extension/ExternalStorage/Disk.pm
@@ -100,7 +100,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};
@@ -109,7 +109,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);
 }
 
 =head1 NAME
diff --git a/lib/RT/Extension/ExternalStorage/Dropbox.pm b/lib/RT/Extension/ExternalStorage/Dropbox.pm
index d57bf6b..6e8bf46 100644
--- a/lib/RT/Extension/ExternalStorage/Dropbox.pm
+++ b/lib/RT/Extension/ExternalStorage/Dropbox.pm
@@ -97,7 +97,7 @@ sub Store {
     my ($sha, $content) = @_;
 
     # 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: $!");
@@ -106,7 +106,7 @@ sub Store {
     close $DROPBOX
         or return (undef, "Flush to dropbox failed: $!");
 
-    return (1);
+    return ($sha);
 }
 
 =head1 NAME

-----------------------------------------------------------------------


More information about the Bps-public-commit mailing list