user/dev discussion of public-inbox itself
 help / color / mirror / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
			download mbox.gz: |
* [PATCH 0/4] cleanup some minor annoyances
@ 2020-08-01  8:12  7% Eric Wong
  2020-08-01  8:12  6% ` [PATCH 2/4] inboxwritable: rename mime_from_path to eml_from_path Eric Wong
  0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2020-08-01  8:12 UTC (permalink / raw)
  To: meta

Just some minor stuff I noticed while tracking down -watch
failures resolved by
https://public-inbox.org/meta/20200731213618.GA19572@dcvr/

Eric Wong (4):
  inboxwritable: mime_from_path: reduce `$/' scope and returns
  inboxwritable: rename mime_from_path to eml_from_path
  searchidx: remove v1-only msg_mime sub
  remove unnecessary ->header_obj calls

 lib/PublicInbox/ContentHash.pm   | 15 +++++++-------
 lib/PublicInbox/Import.pm        | 17 +++++++---------
 lib/PublicInbox/InboxWritable.pm | 25 ++++++++++-------------
 lib/PublicInbox/MID.pm           |  5 +----
 lib/PublicInbox/OverIdx.pm       |  9 ++++----
 lib/PublicInbox/SearchIdx.pm     | 30 ++++++++++++---------------
 lib/PublicInbox/V2Writable.pm    | 35 +++++++++++++++-----------------
 lib/PublicInbox/View.pm          | 35 +++++++++++++++-----------------
 lib/PublicInbox/WatchMaildir.pm  | 10 ++++-----
 lib/PublicInbox/WwwAtomStream.pm |  9 ++++----
 script/public-inbox-edit         | 15 +++++++-------
 script/public-inbox-mda          |  2 +-
 t/search.t                       |  1 +
 13 files changed, 92 insertions(+), 116 deletions(-)

^ permalink raw reply	[relevance 7%]

* [PATCH 2/4] inboxwritable: rename mime_from_path to eml_from_path
  2020-08-01  8:12  7% [PATCH 0/4] cleanup some minor annoyances Eric Wong
@ 2020-08-01  8:12  6% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2020-08-01  8:12 UTC (permalink / raw)
  To: meta

This is more accurate given we use PublicInbox::Eml instead
of Email::MIME/PublicInbox::MIME, nowadays.
---
 lib/PublicInbox/InboxWritable.pm | 9 +++++----
 lib/PublicInbox/WatchMaildir.pm  | 7 +++----
 script/public-inbox-edit         | 9 ++++-----
 3 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/lib/PublicInbox/InboxWritable.pm b/lib/PublicInbox/InboxWritable.pm
index e8ecd3fba..7fb5a150c 100644
--- a/lib/PublicInbox/InboxWritable.pm
+++ b/lib/PublicInbox/InboxWritable.pm
@@ -4,11 +4,12 @@
 # Extends read-only Inbox for writing
 package PublicInbox::InboxWritable;
 use strict;
-use warnings;
-use base qw(PublicInbox::Inbox);
+use v5.10.1;
+use parent qw(PublicInbox::Inbox Exporter);
 use PublicInbox::Import;
 use PublicInbox::Filter::Base qw(REJECT);
 use Errno qw(ENOENT);
+our @EXPORT_OK = qw(eml_from_path);
 
 use constant {
 	PERM_UMASK => 0,
@@ -133,7 +134,7 @@ sub is_maildir_path ($) {
 	(is_maildir_basename($p[-1]) && -f $path) ? 1 : 0;
 }
 
-sub mime_from_path ($) {
+sub eml_from_path ($) {
 	my ($path) = @_;
 	if (open my $fh, '<', $path) {
 		my $str = do { local $/; <$fh> } or return;
@@ -155,7 +156,7 @@ sub import_maildir {
 		opendir my $dh, "$dir/$sub" or die "opendir $dir/$sub: $!\n";
 		while (defined(my $fn = readdir($dh))) {
 			next unless is_maildir_basename($fn);
-			my $mime = mime_from_path("$dir/$fn") or next;
+			my $mime = eml_from_path("$dir/$fn") or next;
 
 			if (my $filter = $self->filter($im)) {
 				my $ret = $filter->scrub($mime) or return;
diff --git a/lib/PublicInbox/WatchMaildir.pm b/lib/PublicInbox/WatchMaildir.pm
index fad708d8f..814b455b2 100644
--- a/lib/PublicInbox/WatchMaildir.pm
+++ b/lib/PublicInbox/WatchMaildir.pm
@@ -7,7 +7,7 @@ package PublicInbox::WatchMaildir;
 use strict;
 use warnings;
 use PublicInbox::Eml;
-use PublicInbox::InboxWritable;
+use PublicInbox::InboxWritable qw(eml_from_path);
 use PublicInbox::Filter::Base qw(REJECT);
 use PublicInbox::Spamcheck;
 use PublicInbox::Sigfd;
@@ -15,7 +15,6 @@ use PublicInbox::DS qw(now);
 use PublicInbox::MID qw(mids);
 use PublicInbox::ContentHash qw(content_hash);
 use POSIX qw(_exit);
-*mime_from_path = \&PublicInbox::InboxWritable::mime_from_path;
 
 sub compile_watchheaders ($) {
 	my ($ibx) = @_;
@@ -154,7 +153,7 @@ sub _remove_spam {
 	my ($self, $path) = @_;
 	# path must be marked as (S)een
 	$path =~ /:2,[A-R]*S[T-Za-z]*\z/ or return;
-	my $eml = mime_from_path($path) or return;
+	my $eml = eml_from_path($path) or return;
 	$self->{config}->each_inbox(\&remove_eml_i, [ $self, $eml, $path ]);
 }
 
@@ -207,7 +206,7 @@ sub _try_path {
 		return _remove_spam($self, $path);
 	}
 	foreach my $ibx (@$inboxes) {
-		my $eml = mime_from_path($path) or next;
+		my $eml = eml_from_path($path) or next;
 		import_eml($self, $ibx, $eml);
 	}
 }
diff --git a/script/public-inbox-edit b/script/public-inbox-edit
index d8e511b2e..2d3c4af4d 100755
--- a/script/public-inbox-edit
+++ b/script/public-inbox-edit
@@ -13,7 +13,7 @@ use PublicInbox::ContentHash qw(content_hash);
 use PublicInbox::MID qw(mid_clean mids);
 PublicInbox::Admin::check_require('-index');
 use PublicInbox::Eml;
-use PublicInbox::InboxWritable;
+use PublicInbox::InboxWritable qw(eml_from_path);
 use PublicInbox::Import;
 
 my $usage = "$0 -m MESSAGE_ID [--all] [INBOX_DIRS]";
@@ -92,11 +92,10 @@ Multiple messages with different content found matching
 		warn "Will edit all of them\n";
 	}
 } else {
-	my $mime = PublicInbox::InboxWritable::mime_from_path($file) or
-		die "open($file) failed: $!";
-	my $mids = mids($mime->header_obj);
+	my $eml = eml_from_path($file) or die "open($file) failed: $!";
+	my $mids = mids($eml->header_obj);
 	find_mid($found, $_, \@ibxs) for (@$mids); # populates $found
-	my $chash = content_hash($mime);
+	my $chash = content_hash($eml);
 	my $to_edit = $found->{$chash};
 	unless ($to_edit) {
 		my $nr = scalar(keys %$found);

^ permalink raw reply	[relevance 6%]

Results 1-2 of 2 | reverse
2020-08-01  8:12  7% [PATCH 0/4] cleanup some minor annoyances Eric Wong
2020-08-01  8:12  6% ` [PATCH 2/4] inboxwritable: rename mime_from_path to eml_from_path Eric Wong

user/dev discussion of public-inbox itself

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/meta
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 meta meta/ https://public-inbox.org/meta \
		meta@public-inbox.org
	public-inbox-index meta

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.mail.public-inbox.meta
	nntp://ou63pmih66umazou.onion/inbox.comp.mail.public-inbox.meta
	nntp://czquwvybam4bgbro.onion/inbox.comp.mail.public-inbox.meta
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.mail.public-inbox.meta
	nntp://news.gmane.io/gmane.mail.public-inbox.general
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for the project(s) associated with this inbox:

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

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git