diff options
author | Eric Wong <e@80x24.org> | 2020-10-27 07:54:16 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2020-11-07 10:18:45 +0000 |
commit | f1bfa6f60344cb2a06d812f8c97d9ba0f5aaad45 (patch) | |
tree | fe43e56f2cfe68537640df8d3cab23f04608fac3 /lib/PublicInbox/InboxWritable.pm | |
parent | e1f70280eec5fc523b8d13de30249d425ff0fab7 (diff) | |
download | public-inbox-f1bfa6f60344cb2a06d812f8c97d9ba0f5aaad45.tar.gz |
We'll be using per-sync-state {ibx} refs instead, so make parts of the v2 indexing code less-dependent on $self->{ibx} where $self is a V2Writable object.
Diffstat (limited to 'lib/PublicInbox/InboxWritable.pm')
-rw-r--r-- | lib/PublicInbox/InboxWritable.pm | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/PublicInbox/InboxWritable.pm b/lib/PublicInbox/InboxWritable.pm index 752f1997..e97c7e2d 100644 --- a/lib/PublicInbox/InboxWritable.pm +++ b/lib/PublicInbox/InboxWritable.pm @@ -298,4 +298,25 @@ sub warn_ignore_cb { } } +# v2+ only +sub git_dir_n { "$_[0]->{inboxdir}/git/$_[1].git" } + +# v2+ only +sub git_dir_latest { + my ($self, $max) = @_; + $$max = -1; + my $pfx = "$self->{inboxdir}/git"; + return unless -d $pfx; + my $latest; + opendir my $dh, $pfx or die "opendir $pfx: $!\n"; + while (defined(my $git_dir = readdir($dh))) { + $git_dir =~ m!\A([0-9]+)\.git\z! or next; + if ($1 > $$max) { + $$max = $1; + $latest = "$pfx/$git_dir"; + } + } + $latest; +} + 1; |