user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 12/12] treewide: shorten temporary filename
Date: Sun, 28 Mar 2021 09:01:24 +0000	[thread overview]
Message-ID: <20210328090124.3541-13-e@80x24.org> (raw)
In-Reply-To: <20210328090124.3541-1-e@80x24.org>

File::Temp only requires four 'X' characters (unlike mkstemp(3),
which requires six).  So only so only give it 4 to avoid an
80-column violation and maybe save metadata space on FSes.
---
 lib/PublicInbox/LeiOverview.pm | 2 +-
 lib/PublicInbox/Msgmap.pm      | 2 +-
 lib/PublicInbox/SolverGit.pm   | 2 +-
 lib/PublicInbox/TestCommon.pm  | 2 +-
 lib/PublicInbox/V2Writable.pm  | 6 +++---
 lib/PublicInbox/Xapcmd.pm      | 9 ++++-----
 script/public-inbox-edit       | 2 +-
 script/public-inbox-init       | 2 +-
 scripts/ssoma-replay           | 2 +-
 t/check-www-inbox.perl         | 2 +-
 t/inbox.t                      | 2 +-
 t/nodatacow.t                  | 2 +-
 12 files changed, 17 insertions(+), 18 deletions(-)

diff --git a/lib/PublicInbox/LeiOverview.pm b/lib/PublicInbox/LeiOverview.pm
index 8e26cba4..68f6c792 100644
--- a/lib/PublicInbox/LeiOverview.pm
+++ b/lib/PublicInbox/LeiOverview.pm
@@ -26,7 +26,7 @@ sub _iso8601 ($) { strftime('%Y-%m-%dT%H:%M:%SZ', gmtime($_[0])) }
 # we open this in the parent process before ->wq_io_do handoff
 sub ovv_out_lk_init ($) {
 	my ($self) = @_;
-	my $tmp = File::Temp->new("lei-ovv.dst.$$.lock-XXXXXX",
+	my $tmp = File::Temp->new("lei-ovv.dst.$$.lock-XXXX",
 					TMPDIR => 1, UNLINK => 0);
 	$self->{"lk_id.$self.$$"} = $self->{lock_path} = $tmp->filename;
 }
diff --git a/lib/PublicInbox/Msgmap.pm b/lib/PublicInbox/Msgmap.pm
index 826c4b30..16a9a476 100644
--- a/lib/PublicInbox/Msgmap.pm
+++ b/lib/PublicInbox/Msgmap.pm
@@ -46,7 +46,7 @@ sub new_file {
 sub tmp_clone {
 	my ($self, $dir) = @_;
 	require File::Temp;
-	my $tmp = "mm_tmp-$$-XXXXXX";
+	my $tmp = "mm_tmp-$$-XXXX";
 	my ($fh, $fn) = File::Temp::tempfile($tmp, EXLOCK => 0, DIR => $dir);
 	PublicInbox::Spawn::nodatacow_fd(fileno($fh));
 	$self->{dbh}->sqlite_backup_to_file($fn);
diff --git a/lib/PublicInbox/SolverGit.pm b/lib/PublicInbox/SolverGit.pm
index 1d70975e..92106e75 100644
--- a/lib/PublicInbox/SolverGit.pm
+++ b/lib/PublicInbox/SolverGit.pm
@@ -681,7 +681,7 @@ sub solve ($$$$$) {
 	$self->{todo} = [ { %$hints, oid_b => $oid_want } ];
 	$self->{patches} = []; # [ $di, $di, ... ]
 	$self->{found} = {}; # { abbr => [ ::Git, oid, type, size, $di ] }
-	$self->{tmp} = File::Temp->newdir("solver.$oid_want-XXXXXXXX", TMPDIR => 1);
+	$self->{tmp} = File::Temp->newdir("solver.$oid_want-XXXX", TMPDIR => 1);
 
 	dbg($self, "solving $oid_want ...");
 	if (my $async = $env->{'pi-httpd.async'}) {
diff --git a/lib/PublicInbox/TestCommon.pm b/lib/PublicInbox/TestCommon.pm
index d36a63aa..d6e090dd 100644
--- a/lib/PublicInbox/TestCommon.pm
+++ b/lib/PublicInbox/TestCommon.pm
@@ -40,7 +40,7 @@ sub tmpdir (;$) {
 	unless (defined $base) {
 		($base) = ($0 =~ m!\b([^/]+)\.[^\.]+\z!);
 	}
-	my $tmpdir = File::Temp->newdir("pi-$base-$$-XXXXXX", TMPDIR => 1);
+	my $tmpdir = File::Temp->newdir("pi-$base-$$-XXXX", TMPDIR => 1);
 	($tmpdir->dirname, $tmpdir);
 }
 
diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm
index 4130a472..0461257f 100644
--- a/lib/PublicInbox/V2Writable.pm
+++ b/lib/PublicInbox/V2Writable.pm
@@ -660,7 +660,7 @@ sub done {
 
 sub write_alternates ($$$) {
 	my ($info_dir, $mode, $out) = @_;
-	my $fh = File::Temp->new(TEMPLATE => 'alt-XXXXXXXX', DIR => $info_dir);
+	my $fh = File::Temp->new(TEMPLATE => 'alt-XXXX', DIR => $info_dir);
 	my $tmp = $fh->filename;
 	print $fh @$out or die "print $tmp: $!\n";
 	chmod($mode, $fh) or die "fchmod $tmp: $!\n";
@@ -772,11 +772,11 @@ sub import_init {
 sub diff ($$$) {
 	my ($mid, $cur, $new) = @_;
 
-	my $ah = File::Temp->new(TEMPLATE => 'email-cur-XXXXXXXX', TMPDIR => 1);
+	my $ah = File::Temp->new(TEMPLATE => 'email-cur-XXXX', TMPDIR => 1);
 	print $ah $cur->as_string or die "print: $!";
 	$ah->flush or die "flush: $!";
 	PublicInbox::Import::drop_unwanted_headers($new);
-	my $bh = File::Temp->new(TEMPLATE => 'email-new-XXXXXXXX', TMPDIR => 1);
+	my $bh = File::Temp->new(TEMPLATE => 'email-new-XXXX', TMPDIR => 1);
 	print $bh $new->as_string or die "print: $!";
 	$bh->flush or die "flush: $!";
 	my $cmd = [ qw(diff -u), $ah->filename, $bh->filename ];
diff --git a/lib/PublicInbox/Xapcmd.pm b/lib/PublicInbox/Xapcmd.pm
index e2d67f6a..9791f02c 100644
--- a/lib/PublicInbox/Xapcmd.pm
+++ b/lib/PublicInbox/Xapcmd.pm
@@ -192,7 +192,7 @@ sub prepare_run {
 		my $dir = dirname($old);
 		same_fs_or_die($dir, $old);
 		my $v = PublicInbox::Search::SCHEMA_VERSION();
-		my $wip = File::Temp->newdir("xapian$v-XXXXXXXX", DIR => $dir);
+		my $wip = File::Temp->newdir("xapian$v-XXXX", DIR => $dir);
 		$tmp->{$old} = $wip;
 		nodatacow_dir($wip->dirname);
 		push @queue, [ $old, $wip ];
@@ -220,8 +220,7 @@ sub prepare_run {
 			$src = [ map { "$old/$_" } @old_shards ];
 		}
 		foreach my $dn (0..$max_shard) {
-			my $tmpl = "$dn-XXXXXXXX";
-			my $wip = File::Temp->newdir($tmpl, DIR => $old);
+			my $wip = File::Temp->newdir("$dn-XXXX", DIR => $old);
 			same_fs_or_die($old, $wip->dirname);
 			my $cur = "$old/$dn";
 			push @queue, [ $src // $cur , $wip ];
@@ -291,7 +290,7 @@ sub cpdb_retryable ($$) {
 }
 
 sub progress_pfx ($) {
-	my ($wip) = @_; # tempdir v2: ([0-9])+-XXXXXXXX
+	my ($wip) = @_; # tempdir v2: ([0-9])+-XXXX
 	my @p = split('/', $wip);
 
 	# return "xap15/0" for v2, or "xapian15" for v1:
@@ -418,7 +417,7 @@ sub cpdb ($$) { # cb_spawn callback
 	if ($opt->{compact}) {
 		my $dir = dirname($new);
 		same_fs_or_die($dir, $new);
-		$ft = File::Temp->newdir("$new.compact-XXXXXX", DIR => $dir);
+		$ft = File::Temp->newdir("$new.compact-XXXX", DIR => $dir);
 		setup_signals();
 		$tmp = $ft->dirname;
 		nodatacow_dir($tmp);
diff --git a/script/public-inbox-edit b/script/public-inbox-edit
index 1c6c4e4a..9498038b 100755
--- a/script/public-inbox-edit
+++ b/script/public-inbox-edit
@@ -133,7 +133,7 @@ $mids
 }
 
 my %tmpopt = (
-	TEMPLATE => 'public-inbox-edit-XXXXXX',
+	TEMPLATE => 'public-inbox-edit-XXXX',
 	TMPDIR => 1,
 	SUFFIX => $opt->{raw} ? '.eml' : '.mbox',
 );
diff --git a/script/public-inbox-init b/script/public-inbox-init
index e93cab73..335eb476 100755
--- a/script/public-inbox-init
+++ b/script/public-inbox-init
@@ -79,7 +79,7 @@ PublicInbox::Lock::lock_acquire($lock_obj);
 
 # git-config will operate on this (and rename on success):
 require File::Temp;
-my $fh = File::Temp->new(TEMPLATE => 'pi-init-XXXXXXXX', DIR => $dir);
+my $fh = File::Temp->new(TEMPLATE => 'pi-init-XXXX', DIR => $dir);
 
 # Now, we grab another lock to use git-config(1) locking, so it won't
 # wait on the lock, unlike some of our internal flock()-based locks.
diff --git a/scripts/ssoma-replay b/scripts/ssoma-replay
index cfb0fbd9..70d0081d 100755
--- a/scripts/ssoma-replay
+++ b/scripts/ssoma-replay
@@ -29,7 +29,7 @@ use strict;
 use Email::Simple;
 use URI::Escape qw/uri_escape_utf8/;
 use File::Temp qw/tempfile/;
-my ($fh, $filename) = tempfile('ssoma-replay-XXXXXXXX', TMPDIR => 1);
+my ($fh, $filename) = tempfile('ssoma-replay-XXXX', TMPDIR => 1);
 my $msg = Email::Simple->new(do { local $/; <STDIN> });
 select $fh;
 
diff --git a/t/check-www-inbox.perl b/t/check-www-inbox.perl
index eee8adc2..033b90d1 100644
--- a/t/check-www-inbox.perl
+++ b/t/check-www-inbox.perl
@@ -91,7 +91,7 @@ foreach my $p (1..$nproc) {
 	}
 }
 
-my ($fh, $tmp) = tempfile('www-check-XXXXXXXX',
+my ($fh, $tmp) = tempfile('www-check-XXXX',
 			SUFFIX => '.gdbm', UNLINK => 1, TMPDIR => 1);
 my $gdbm = tie my %seen, 'GDBM_File', $tmp, &GDBM_WRCREAT, 0600;
 defined $gdbm or die "gdbm open failed: $!\n";
diff --git a/t/inbox.t b/t/inbox.t
index b7239e6d..0580cd23 100644
--- a/t/inbox.t
+++ b/t/inbox.t
@@ -13,7 +13,7 @@ is($x->base_url, 'http://example.com/test/', 'added trailing slash');
 $x = PublicInbox::Inbox->new({});
 
 is($x->base_url, undef, 'undef base_url allowed');
-my $tmpdir = File::Temp->newdir('pi-inbox-XXXXXX', TMPDIR => 1);
+my $tmpdir = File::Temp->newdir('pi-inbox-XXXX', TMPDIR => 1);
 $x->{inboxdir} = $tmpdir->dirname;
 is_deeply($x->cloneurl, [], 'no cloneurls');
 is($x->description, '($INBOX_DIR/description missing)', 'default description');
diff --git a/t/nodatacow.t b/t/nodatacow.t
index 72860d43..9b67c521 100644
--- a/t/nodatacow.t
+++ b/t/nodatacow.t
@@ -15,7 +15,7 @@ SKIP: {
 	skip 'BTRFS_TESTDIR not defined', $nr unless defined $dir;
 	skip 'chattr(1) not installed', $nr unless which('chattr');
 	my $lsattr = which('lsattr') or skip 'lsattr(1) not installed', $nr;
-	my $tmp = File::Temp->newdir('nodatacow-XXXXX', DIR => $dir);
+	my $tmp = File::Temp->newdir('nodatacow-XXXX', DIR => $dir);
 	my $dn = $tmp->dirname;
 
 	my $name = "$dn/pp.f";

      parent reply	other threads:[~2021-03-28  9:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-28  9:01 [PATCH 00/12] lei blob and some yak-shaving Eric Wong
2021-03-28  9:01 ` [PATCH 01/12] lei: simplify PktOp callers Eric Wong
2021-03-28  9:01 ` [PATCH 02/12] lei init: split out into separate file Eric Wong
2021-03-28  9:01 ` [PATCH 03/12] lei blob: dclose if already failed Eric Wong
2021-03-28  9:01 ` [PATCH 04/12] lei blob: support --no-mail switch Eric Wong
2021-03-28  9:01 ` [PATCH 05/12] lei blob: fail early if no git dirs Eric Wong
2021-03-28  9:01 ` [PATCH 06/12] lei blob: some extra tests Eric Wong
2021-03-28  9:01 ` [PATCH 07/12] lei help: show "NAME=VALUE" properly for -c Eric Wong
2021-03-28  9:01 ` [PATCH 08/12] lei blob: flesh out help text Eric Wong
2021-03-28  9:01 ` [PATCH 09/12] t/lei_store: ensure LeiSearch responds to ->isrch Eric Wong
2021-03-28  9:01 ` [PATCH 10/12] lei blob: add remote external support Eric Wong
2021-03-28  9:01 ` [PATCH 11/12] lei: drop coderepo placeholders, submodule TODO Eric Wong
2021-03-28  9:31   ` Eric Wong
2021-03-28  9:01 ` Eric Wong [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210328090124.3541-13-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    --subject='Re: [PATCH 12/12] treewide: shorten temporary filename' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.mail.public-inbox.meta
	nntp://ie5yzdi7fg72h7s4sdcztq5evakq23rdt33mfyfcddc5u3ndnw24ogqd.onion/inbox.comp.mail.public-inbox.meta
	nntp://4uok3hntl7oi7b4uf4rtfwefqeexfzil2w6kgk2jn5z2f764irre7byd.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 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