lib/PublicInbox/LeiEditSearch.pm
lib/PublicInbox/LeiExportKw.pm
lib/PublicInbox/LeiExternal.pm
+lib/PublicInbox/LeiForgetMailSync.pm
lib/PublicInbox/LeiForgetSearch.pm
lib/PublicInbox/LeiHelp.pm
lib/PublicInbox/LeiImport.pm
qw(stdin| offset=i recursive|r exclude=s include|I=s
lock=s@ in-format|F=s kw! verbose|v+ incremental! mail-sync!),
qw(no-torsocks torsocks=s), PublicInbox::LeiQuery::curl_opt(), @c_opt ],
-
+'forget-mail-sync' => [ 'LOCATION...',
+ 'forget sync information for a mail folder', @c_opt ],
'export-kw' => [ 'LOCATION...|--all',
'one-time export of keywords of sync sources',
qw(all:s mode=s), @c_opt ],
--- /dev/null
+# Copyright (C) 2021 all contributors <meta@public-inbox.org>
+# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
+
+# "lei forget-mail-sync" drop synchronization information
+# TODO: figure out what to do about "lei index" users having
+# dangling references. Perhaps just documenting "lei index"
+# use being incompatible with "forget-mail-sync" use is
+# sufficient.
+
+package PublicInbox::LeiForgetMailSync;
+use strict;
+use v5.10.1;
+use PublicInbox::LeiExportKw;
+
+sub lei_forget_mail_sync {
+ my ($lei, @folders) = @_;
+ my $sto = $lei->_lei_store or return;
+ my $lms = $sto->search->lms or return;
+ my $err = $lms->arg2folder($lei, \@folders);
+ $lei->qerr(@{$err->{qerr}}) if $err->{qerr};
+ return $lei->fail($err->{fail}) if $err->{fail};
+ delete $lms->{dbh};
+ $lms->lms_begin;
+ $lms->forget_folder($_) for @folders;
+ $lms->lms_commit;
+}
+
+*_complete_forget_mail_sync = \&PublicInbox::LeiExportKw::_complete_export_kw;
+
+1;
$err;
}
+sub forget_folder {
+ my ($self, $folder) = @_;
+ my ($fid, $sth);
+ $fid = delete($self->{fmap}->{$folder}) //
+ _fid_for($self, $folder) // return;
+ my $dbh = $self->{dbh};
+ $dbh->do('DELETE FROM blob2name WHERE fid = ?', undef, $fid);
+ $dbh->do('DELETE FROM blob2num WHERE fid = ?', undef, $fid);
+ $dbh->do('DELETE FROM folders WHERE fid = ?', undef, $fid);
+}
+
1;
like($lei_out, qr!^Content-Type: multipart/mixed;!sm, 'got full blob');
lei_ok('blob', "$psgi_attach:2");
is($lei_out, "b64\xde\xad\xbe\xef\n", 'got attachment');
+
+ lei_ok 'forget-mail-sync', $url;
+ lei_ok 'ls-mail-sync';
+ unlike($lei_out, qr!\Q$host_port\E!, 'sync info gone after forget');
});
done_testing;