PublicI...::Import(3)
π PublicInbox::Import π
okay so bestie, welcome to the PublicInbox::Import(3) page, straight outta the User Contributed Perl Documentation collection. she's a Perl module, she's a whole personality, and she's about to import your messages. let's get into it π«Ά
β¨ NAME β¨
PublicInbox::Import β the message importer for public-inbox v1 inboxes. that's the job. that's the whole job. π
π VERSION π
version 1.0 β a real one. π
π¦ SYNOPSIS π¦
look at her go:
use PublicInbox::Eml;
# PublicInbox::Eml exists as of public-inbox 1.5.0,
# Email::MIME was used in older versions
use PublicInbox::Git;
use PublicInbox::Import;
chomp(my $git_dir = `git rev-parse --git-dir`);
$git_dir or die "GIT_DIR= must be specified\n";
my $git = PublicInbox::Git->new($git_dir);
my @committer = ('inbox', 'inbox@example.org');
my $im = PublicInbox::Import->new($git, @committer);
# to add a message:
my $message = "From: <u\@example.org>\n".
"Subject: test message \n" .
"Date: Thu, 01 Jan 1970 00:00:00 +0000\n" .
"Message-ID: <m\@example.org>\n".
"\ntest message";
my $parsed = PublicInbox::Eml->new($message);
my $ret = $im->add($parsed);
if (!defined $ret) {
warn "duplicate: ", $parsed->header_raw('Message-ID'), "\n";
} else {
print "imported at mark $ret\n";
}
$im->done;
# to remove a message
my $junk = PublicInbox::Eml->new($message);
my ($mark, $orig) = $im->remove($junk);
if ($mark eq 'MISSING') {
print "not found\n";
} elsif ($mark eq 'MISMATCH') {
print "Message exists but does not match\n\n",
$orig->as_string, "\n",;
} else {
print "removed at mark $mark\n\n",
$orig->as_string, "\n";
}
$im->done;
like... she adds, she removes, she says goodbye. main character energy fr fr. π
π DESCRIPTION π
so what is this thing? she's an importer and a remover for public-inboxes. you feed her PublicInbox::Eml or Email::MIME messages, and she tucks them away into a git repository β exactly the way it's documented at https://public-inbox.org/public-inbox-v1-format.txt.
but here's the plot twist, bestie: she does not allow duplicate Message-IDs. not one. not ever. she said "one Message-ID, one message" and honestly? valid.
also she needs friends to function: git(1) and git-fast-import(1) both have to be installed on your system, no cap. π
π METHODS π
π«Ά new π«Ά
my $im = PublicInbox::Import->new($git, @committer);
initializes a brand-new PublicInbox::Import object. that's it, that's the whole ritual. light some candles, pass in your git and your committer, and boom β she's alive. β¨
π add π
my $parsed = PublicInbox::Eml->new($message);
$im->add($parsed);
adds a message to the git repository. to do that, she will acquire $GIT_DIR/ssoma.lock and start up git-fast-import(1) if it isn't already running. very "let me just get my things in order first" of her. π
π¨ important tea: messages you add are not visible to other processes untildoneis called. but you can still callremoveon them in the meantime. iykyk.
π§ remove π§
my $junk = PublicInbox::Eml->new($message);
my ($code, $orig) = $im->remove($junk);
removes a message from the repository. and this is where it gets juicy, so pay attention:
- π’ on success, she returns a
':'-prefixed numeric code that represents the git-fast-import mark, plus the original message as aPublicInbox::Eml(orEmail::MIME) object. slay. - π΄ if the message could not be found, the code is
"MISSING"and the original message isundef. gone. ghosted. π - π‘ if there's a mismatch β meaning the
"Message-ID"matched but the subject and body do not match β the returned code is"MISMATCH"and the conflicting message gets returned as orig. awkward!! π
π done π
finalizes the git-fast-import(1) and unlocks the repository.
β οΈ bestie, listen: calling this is required to finalize changes to a repository. no done, no finished changes. periodt.
π SEE ALSO π
Email::MIME
π CONTACT π
all feedback is welcome, and she wants it via plain-text mail to meta@public-inbox.org (that's <mailto:meta@public-inbox.org>). very demure, very mindful, very plain-text. π
the mail archives live at https://public-inbox.org/meta/ if you wanna go snooping (affectionately). π¦
π COPYRIGHT π
Copyright (C) 2016-2020 all contributors <mailto:meta@public-inbox.org>
License: AGPL-3.0+ http://www.gnu.org/licenses/agpl-3.0.txt
and that's the whole page, bestie!! π₯³ this was perl v5.42.0, dated 2025-07-25, and she's filed under PublicI...::Import(3) β yes the name is truncated, she's mysterious like that. mwah π go import something. ππβ¨
π¦ where this page comes from
- fedora 43: perl-PublicInbox 2.0.0~20230714git590023f-6.fc43 Β· AGPL-3.0-or-later
- fedora 44: perl-PublicInbox 2.0.0~20230714git590023f-6.fc43 Β· AGPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms