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 08/11] AdminEdit: move editability checks from -purge
  2019-06-09  2:51  7% [PATCH 00/11] v2: implement message editing Eric Wong (Contractor, The Linux Foundation)
@ 2019-06-09  2:51  6% ` Eric Wong (Contractor, The Linux Foundation)
  0 siblings, 0 replies; 2+ results
From: Eric Wong (Contractor, The Linux Foundation) @ 2019-06-09  2:51 UTC (permalink / raw)
  To: meta

We'll be reusing the same logic for -edit
---
 lib/PublicInbox/AdminEdit.pm | 39 ++++++++++++++++++++++++++++++++++++
 script/public-inbox-purge    | 35 +-------------------------------
 2 files changed, 40 insertions(+), 34 deletions(-)

diff --git a/lib/PublicInbox/AdminEdit.pm b/lib/PublicInbox/AdminEdit.pm
index 109a99f..b27c831 100644
--- a/lib/PublicInbox/AdminEdit.pm
+++ b/lib/PublicInbox/AdminEdit.pm
@@ -8,4 +8,43 @@ use warnings;
 use PublicInbox::Admin;
 our @OPT = qw(all force|f verbose|v!);
 
+sub check_editable ($) {
+	my ($ibxs) = @_;
+
+	foreach my $ibx (@$ibxs) {
+		my $lvl = $ibx->{indexlevel};
+		if (defined $lvl) {
+			PublicInbox::Admin::indexlevel_ok_or_die($lvl);
+			next;
+		}
+
+		# Undefined indexlevel, so `full'...
+		# Search::Xapian exists and the DB can be read, at least, fine
+		$ibx->search and next;
+
+		# it's possible for a Xapian directory to exist,
+		# but Search::Xapian to go missing/broken.
+		# Make sure it's purged in that case:
+		$ibx->over or die "no over.sqlite3 in $ibx->{mainrepo}\n";
+
+		# $ibx->{search} is populated by $ibx->over call
+		my $xdir_ro = $ibx->{search}->xdir(1);
+		my $npart = 0;
+		foreach my $part (<$xdir_ro/*>) {
+			if (-d $part && $part =~ m!/[0-9]+\z!) {
+				my $bytes = 0;
+				$bytes += -s $_ foreach glob("$part/*");
+				$npart++ if $bytes;
+			}
+		}
+		if ($npart) {
+			PublicInbox::Admin::require_or_die('-search');
+		} else {
+			# somebody could "rm -r" all the Xapian directories;
+			# let them purge the overview, at least
+			$ibx->{indexlevel} ||= 'basic';
+		}
+	}
+}
+
 1;
diff --git a/script/public-inbox-purge b/script/public-inbox-purge
index dc7f89d..846557c 100755
--- a/script/public-inbox-purge
+++ b/script/public-inbox-purge
@@ -21,40 +21,7 @@ GetOptions($opt, @PublicInbox::AdminEdit::OPT) or
 	die "bad command-line args\n$usage\n";
 
 my @ibxs = PublicInbox::Admin::resolve_inboxes(\@ARGV, $opt);
-
-foreach my $ibx (@ibxs) {
-	my $lvl = $ibx->{indexlevel};
-	if (defined $lvl) {
-		PublicInbox::Admin::indexlevel_ok_or_die($lvl);
-		next;
-	}
-
-	# Undefined indexlevel, so `full'...
-	# Search::Xapian exists and the DB can be read, at least, fine
-	$ibx->search and next;
-
-	# it's possible for a Xapian directory to exist, but Search::Xapian
-	# to go missing/broken.  Make sure it's purged in that case:
-	$ibx->over or die "no over.sqlite3 in $ibx->{mainrepo}\n";
-
-	# $ibx->{search} is populated by $ibx->over call
-	my $xdir_ro = $ibx->{search}->xdir(1);
-	my $npart = 0;
-	foreach my $part (<$xdir_ro/*>) {
-		if (-d $part && $part =~ m!/[0-9]+\z!) {
-			my $bytes = 0;
-			$bytes += -s $_ foreach glob("$part/*");
-			$npart++ if $bytes;
-		}
-	}
-	if ($npart) {
-		PublicInbox::Admin::require_or_die('-search');
-	} else {
-		# somebody could "rm -r" all the Xapian directories;
-		# let them purge the overview, at least
-		$ibx->{indexlevel} ||= 'basic';
-	}
-}
+PublicInbox::AdminEdit::check_editable(\@ibxs);
 
 my $data = do { local $/; scalar <STDIN> };
 $data =~ s/\A[\r\n]*From [^\r\n]*\r?\n//s;
-- 
EW


^ permalink raw reply related	[relevance 6%]

* [PATCH 00/11] v2: implement message editing
@ 2019-06-09  2:51  7% Eric Wong (Contractor, The Linux Foundation)
  2019-06-09  2:51  6% ` [PATCH 08/11] AdminEdit: move editability checks from -purge Eric Wong (Contractor, The Linux Foundation)
  0 siblings, 1 reply; 2+ results
From: Eric Wong (Contractor, The Linux Foundation) @ 2019-06-09  2:51 UTC (permalink / raw)
  To: meta

Some organizations are legally responsible for removing certain
content but prefer to edit out sensitive parts of a message
instead of purging it completely from history.

We can build off existing purge functionality.  Instead of
replacing a message with an empty file; we instead replace
it with the desired content.

This ->replace method reindexes the modified message and
updates the corresponding git commit in case the subject
or authorship ident changes.

A new tool, public-inbox-edit(1) wraps the new ->replace
functionality by providing an editable mboxrd (suitable
for publicinbox.mailEditor "mutt -f").

GIT_EDITOR/VISUAL/EDITOR can be used if publicinbox.mailEditor
is not configured, but those are generally not ideal
for editing base64 or QP-encoded messages.

Eric Wong (Contractor, The Linux Foundation) (11):
  v2writable: consolidate overview and indexing call
  import: extract_author_info becomes extract_commit_info
  import: switch to "replace_oids" interface for purge
  v2writable: implement ->replace call
  admin: remove warning arg for unconfigured inboxes
  purge: start moving common options to AdminEdit module
  admin: beef up resolve_inboxes to handle purge options
  AdminEdit: move editability checks from -purge
  admin: expose ->config
  doc: document the --prune option for -index
  edit: new tool to perform edits

 Documentation/include.mk              |   1 +
 Documentation/public-inbox-config.pod |   4 +
 Documentation/public-inbox-edit.pod   | 109 ++++++++++++
 Documentation/public-inbox-index.pod  |   7 +
 MANIFEST                              |   5 +
 lib/PublicInbox/Admin.pm              |  75 ++++++---
 lib/PublicInbox/AdminEdit.pm          |  50 ++++++
 lib/PublicInbox/Import.pm             | 101 ++++++-----
 lib/PublicInbox/V2Writable.pm         | 200 +++++++++++++++++-----
 script/public-inbox-edit              | 233 ++++++++++++++++++++++++++
 script/public-inbox-purge             | 103 ++----------
 t/edit.t                              | 178 ++++++++++++++++++++
 t/replace.t                           | 199 ++++++++++++++++++++++
 13 files changed, 1065 insertions(+), 200 deletions(-)
 create mode 100644 Documentation/public-inbox-edit.pod
 create mode 100644 lib/PublicInbox/AdminEdit.pm
 create mode 100755 script/public-inbox-edit
 create mode 100644 t/edit.t
 create mode 100644 t/replace.t

-- 
EW


^ permalink raw reply	[relevance 7%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2019-06-09  2:51  7% [PATCH 00/11] v2: implement message editing Eric Wong (Contractor, The Linux Foundation)
2019-06-09  2:51  6% ` [PATCH 08/11] AdminEdit: move editability checks from -purge Eric Wong (Contractor, The Linux Foundation)

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).