diff options
author | Eric Wong <e@80x24.org> | 2019-11-15 09:50:33 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2019-11-16 11:05:23 +0000 |
commit | 10fad7e1cf3eb0a4874afa1cb5ddb3d75afeec7d (patch) | |
tree | 7f11102118327e8e12283e42aa758cafd03bb46b /script | |
parent | 04d0b9c097cc8f6d5868c4e072710baaf870f99c (diff) | |
download | public-inbox-10fad7e1cf3eb0a4874afa1cb5ddb3d75afeec7d.tar.gz |
Instead of relying on END{} blocks, rely on ->DESTROY so the temporary files go out-of-scope and system resources get released, sooner.
Diffstat (limited to 'script')
-rwxr-xr-x | script/public-inbox-edit | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/script/public-inbox-edit b/script/public-inbox-edit index c9884053..0accd7c1 100755 --- a/script/public-inbox-edit +++ b/script/public-inbox-edit @@ -8,7 +8,7 @@ use strict; use warnings; use Getopt::Long qw(:config gnu_getopt no_ignore_case auto_abbrev); use PublicInbox::AdminEdit; -use File::Temp qw(tempfile); +use File::Temp (); use PublicInbox::ContentId qw(content_id); use PublicInbox::MID qw(mid_clean mids); PublicInbox::Admin::check_require('-index'); @@ -120,10 +120,16 @@ $mids $found = { $cid => $to_edit }; } -my $tmpl = 'public-inbox-edit-XXXXXX'; +my %tmpopt = ( + TEMPLATE => 'public-inbox-edit-XXXXXX', + TMPDIR => 1, + SUFFIX => $opt->{raw} ? '.eml' : '.mbox', +); + foreach my $to_edit (values %$found) { - my ($edit_fh, $edit_fn) = tempfile($tmpl, TMPDIR => 1, UNLINK => 1); + my $edit_fh = File::Temp->new(%tmpopt); $edit_fh->autoflush(1); + my $edit_fn = $edit_fh->filename; my ($ibx, $smsg) = @{$to_edit->[0]}; my $old_raw = $ibx->msg_by_smsg($smsg); delete @$ibx{qw(over mm git search)}; # cleanup |