about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-09-16 09:41:14 +0000
committerEric Wong <e@80x24.org>2021-09-16 20:09:35 +0000
commitb833e4095c6dab8d81bbcdedaddafa4b6a2a235c (patch)
tree6c3673793096d3fb5b584d44a855bbc5c290ae34 /lib
parent9d65d8e41fa69c0f0a13789754c5d6dc5f699b8a (diff)
downloadpublic-inbox-b833e4095c6dab8d81bbcdedaddafa4b6a2a235c.tar.gz
We'll be using binary SHA-1 and SHA-256 in-memory since that's
what mail_sync.sqlite3 stores.
Diffstat (limited to 'lib')
-rw-r--r--lib/PublicInbox/LEI.pm10
-rw-r--r--lib/PublicInbox/LeiInspect.pm3
-rw-r--r--lib/PublicInbox/LeiRemote.pm2
-rw-r--r--lib/PublicInbox/LeiStore.pm9
-rw-r--r--lib/PublicInbox/LeiXSearch.pm3
5 files changed, 13 insertions, 14 deletions
diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm
index 0a30bc36..ec103231 100644
--- a/lib/PublicInbox/LEI.pm
+++ b/lib/PublicInbox/LEI.pm
@@ -24,6 +24,8 @@ use PublicInbox::DS qw(now dwaitpid);
 use PublicInbox::Spawn qw(spawn popen_rd);
 use PublicInbox::Lock;
 use PublicInbox::Eml;
+use PublicInbox::Import;
+use PublicInbox::ContentHash qw(git_sha);
 use Time::HiRes qw(stat); # ctime comparisons for config cache
 use File::Path qw(mkpath);
 use File::Spec;
@@ -1479,9 +1481,11 @@ sub refresh_watches {
         }
 }
 
-sub git_blob_id {
-        my ($lei, $eml) = @_;
-        ($lei->{sto} // _lei_store($lei, 1))->git_blob_id($eml);
+# TODO: support SHA-256
+sub git_oid {
+        my $eml = $_[-1];
+        $eml->header_set($_) for @PublicInbox::Import::UNWANTED_HEADERS;
+        git_sha(1, $eml);
 }
 
 sub lms { # read-only LeiMailSync
diff --git a/lib/PublicInbox/LeiInspect.pm b/lib/PublicInbox/LeiInspect.pm
index 25bd47e7..2385f7f8 100644
--- a/lib/PublicInbox/LeiInspect.pm
+++ b/lib/PublicInbox/LeiInspect.pm
@@ -202,7 +202,8 @@ sub ins_add { # InputPipe->consume callback
                         my $str = delete $lei->{istr};
                         $str =~ s/\A[\r\n]*From [^\r\n]*\r?\n//s;
                         my $eml = PublicInbox::Eml->new(\$str);
-                        _inspect_argv($lei, [ 'blob:'.$lei->git_blob_id($eml),
+                        _inspect_argv($lei, [
+                                'blob:'.$lei->git_oid($eml)->hexdigest,
                                 map { "mid:$_" } @{mids($eml)} ]);
                 };
                 $lei->{istr} .= $_[1];
diff --git a/lib/PublicInbox/LeiRemote.pm b/lib/PublicInbox/LeiRemote.pm
index 580787c0..8d4ffed0 100644
--- a/lib/PublicInbox/LeiRemote.pm
+++ b/lib/PublicInbox/LeiRemote.pm
@@ -32,7 +32,7 @@ sub _each_mboxrd_eml { # callback for MboxReader->mboxrd
                 $smsg = $res if ref($res) eq ref($smsg);
         }
         $smsg->{blob} //= $xoids ? (keys(%$xoids))[0]
-                                : $lei->git_blob_id($eml);
+                                : $lei->git_oid($eml)->hexdigest;
         $smsg->populate($eml);
         $smsg->{mid} //= '(none)';
         push @{$self->{smsg}}, $smsg;
diff --git a/lib/PublicInbox/LeiStore.pm b/lib/PublicInbox/LeiStore.pm
index 42f574f2..e8bcb04e 100644
--- a/lib/PublicInbox/LeiStore.pm
+++ b/lib/PublicInbox/LeiStore.pm
@@ -20,7 +20,7 @@ use PublicInbox::Eml;
 use PublicInbox::Import;
 use PublicInbox::InboxWritable qw(eml_from_path);
 use PublicInbox::V2Writable;
-use PublicInbox::ContentHash qw(content_hash git_sha);
+use PublicInbox::ContentHash qw(content_hash);
 use PublicInbox::MID qw(mids);
 use PublicInbox::LeiSearch;
 use PublicInbox::MDA;
@@ -603,13 +603,6 @@ sub write_prepare {
         $lei->{sto} = $self;
 }
 
-# TODO: support SHA-256
-sub git_blob_id { # called via LEI->git_blob_id
-        my ($self, $eml) = @_;
-        $eml->header_set($_) for @PublicInbox::Import::UNWANTED_HEADERS;
-        git_sha(1, $eml)->hexdigest;
-}
-
 # called by lei-daemon before lei->refresh_watches
 sub add_sync_folders {
         my ($self, @folders) = @_;
diff --git a/lib/PublicInbox/LeiXSearch.pm b/lib/PublicInbox/LeiXSearch.pm
index 556ffd58..50cadb5e 100644
--- a/lib/PublicInbox/LeiXSearch.pm
+++ b/lib/PublicInbox/LeiXSearch.pm
@@ -275,7 +275,8 @@ sub each_remote_eml { # callback for MboxReader->mboxrd
                         $smsg->{kw} = []; # short-circuit xsmsg_vmd
                 }
         }
-        $smsg->{blob} //= $xoids ? (keys(%$xoids))[0] : $lei->git_blob_id($eml);
+        $smsg->{blob} //= $xoids ? (keys(%$xoids))[0]
+                                : $lei->git_oid($eml)->hexdigest;
         _smsg_fill($smsg, $eml);
         wait_startq($lei);
         if ($lei->{-progress}) {