user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 0/3] lei refresh-mail-sync
@ 2021-09-16  9:41  7% Eric Wong
  2021-09-16  9:41  5% ` [PATCH 1/3] lei: git_oid: replace git_blob_id Eric Wong
  0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2021-09-16  9:41 UTC (permalink / raw)
  To: meta

The command I need because lei-daemon keeps dying so inotify
ain't useful :P  Well, actually, I just restart lei-daemon
frequently because I'm always changing code.

1/3 is a nice cleanup, 2/3 makes the change

AFAIK, refresh-mail-sync (and prune-mail-sync before it)
were the only which could trigger the bug fixed in PATCH 3/3

Eric Wong (3):
  lei: git_oid: replace git_blob_id
  lei refresh-mail-sync: replace prune-mail-sync
  net_reader: ensure IO::Socket::Socks is loaded in all workers

 MANIFEST                                      |  2 +
 lib/PublicInbox/LEI.pm                        | 13 ++--
 lib/PublicInbox/LeiInspect.pm                 |  3 +-
 ...PruneMailSync.pm => LeiRefreshMailSync.pm} | 36 +++++++---
 lib/PublicInbox/LeiRemote.pm                  |  2 +-
 lib/PublicInbox/LeiStore.pm                   | 14 ++--
 lib/PublicInbox/LeiXSearch.pm                 |  3 +-
 lib/PublicInbox/NetReader.pm                  |  5 ++
 t/lei-export-kw.t                             |  1 -
 t/lei-refresh-mail-sync.t                     | 67 +++++++++++++++++++
 10 files changed, 121 insertions(+), 25 deletions(-)
 rename lib/PublicInbox/{LeiPruneMailSync.pm => LeiRefreshMailSync.pm} (70%)
 create mode 100644 t/lei-refresh-mail-sync.t


^ permalink raw reply	[relevance 7%]

* [PATCH 1/3] lei: git_oid: replace git_blob_id
  2021-09-16  9:41  7% [PATCH 0/3] lei refresh-mail-sync Eric Wong
@ 2021-09-16  9:41  5% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2021-09-16  9:41 UTC (permalink / raw)
  To: meta

We'll be using binary SHA-1 and SHA-256 in-memory since that's
what mail_sync.sqlite3 stores.
---
 lib/PublicInbox/LEI.pm        | 10 +++++++---
 lib/PublicInbox/LeiInspect.pm |  3 ++-
 lib/PublicInbox/LeiRemote.pm  |  2 +-
 lib/PublicInbox/LeiStore.pm   |  9 +--------
 lib/PublicInbox/LeiXSearch.pm |  3 ++-
 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}) {

^ permalink raw reply related	[relevance 5%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2021-09-16  9:41  7% [PATCH 0/3] lei refresh-mail-sync Eric Wong
2021-09-16  9:41  5% ` [PATCH 1/3] lei: git_oid: replace git_blob_id Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).