]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei: git_oid: replace git_blob_id
authorEric Wong <e@80x24.org>
Thu, 16 Sep 2021 09:41:14 +0000 (09:41 +0000)
committerEric Wong <e@80x24.org>
Thu, 16 Sep 2021 20:09:35 +0000 (20:09 +0000)
We'll be using binary SHA-1 and SHA-256 in-memory since that's
what mail_sync.sqlite3 stores.

lib/PublicInbox/LEI.pm
lib/PublicInbox/LeiInspect.pm
lib/PublicInbox/LeiRemote.pm
lib/PublicInbox/LeiStore.pm
lib/PublicInbox/LeiXSearch.pm

index 0a30bc36d96baf5b367252779143952ea6b4dd75..ec10323155cd8cbeeea258b7acb732f454fd72cf 100644 (file)
@@ -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
index 25bd47e79819194322d161f516f53fac9175ca5d..2385f7f82fe6499aae4941ab9961e00a59a14697 100644 (file)
@@ -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];
index 580787c042c4e317d7c79ddab425c05b0816d2f3..8d4ffed0c03b9bc6f75bc64a784f34165b71c107 100644 (file)
@@ -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;
index 42f574f27d579cddcc53772e2c01409e25187714..e8bcb04e972bcf31945f13800ac04be2bb3bf3c9 100644 (file)
@@ -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) = @_;
index 556ffd58ff7c969f536ef179cee01414a92fa4de..50cadb5eca5b9905e8ce065cf57843813dfacea4 100644 (file)
@@ -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}) {