]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Lock.pm
lei_to_mail: start --augment, dedupe, bz2 and xz
[public-inbox.git] / lib / PublicInbox / Lock.pm
index 7fd1774584c3df93b80ebad3f2e6f5ad4bdc8229..f6eaa5ce1101128eef02885f444e09b08f5fcbb1 100644 (file)
@@ -8,6 +8,7 @@ use v5.10.1;
 use Fcntl qw(:flock :DEFAULT);
 use Carp qw(croak);
 use PublicInbox::OnDestroy;
+use File::Temp ();
 
 # we only acquire the flock if creating or reindexing;
 # PublicInbox::Import already has the lock on its own.
@@ -40,4 +41,10 @@ sub lock_for_scope {
        PublicInbox::OnDestroy->new(\&lock_release, $self);
 }
 
+sub new_tmp {
+       my ($cls, $ident) = @_;
+       my $tmp = File::Temp->new("$ident.lock-XXXXXX", TMPDIR => 1);
+       bless { lock_path => $tmp->filename, tmp => $tmp }, $cls;
+}
+
 1;