get rid of wasted parse in wild_repo_rights
This commit is contained in:
parent
c642d9660e
commit
d8789a3af0
|
@ -307,16 +307,10 @@ sub new_repo
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
{
|
{
|
||||||
# the following sub needs some persistent data, so we make a closure
|
# the following subs need some persistent data, so we make a closure
|
||||||
my $cache_filled = 0;
|
my $cache_filled = 0;
|
||||||
my %cached_groups;
|
my %cached_groups;
|
||||||
|
sub fill_cache {
|
||||||
# "who created this repo", "am I on the R list", and "am I on the RW list"?
|
|
||||||
sub wild_repo_rights
|
|
||||||
{
|
|
||||||
# set default categories
|
|
||||||
$GL_WILDREPOS_PERM_CATS ||= "READERS WRITERS";
|
|
||||||
my ($repo, $user) = @_;
|
|
||||||
# pull in basic group info
|
# pull in basic group info
|
||||||
unless ($cache_filled) {
|
unless ($cache_filled) {
|
||||||
local(%repos, %groups);
|
local(%repos, %groups);
|
||||||
|
@ -328,10 +322,18 @@ sub new_repo
|
||||||
# really care; we just pull it in once and save it for the rest of
|
# really care; we just pull it in once and save it for the rest of
|
||||||
# the run
|
# the run
|
||||||
do $GL_CONF_COMPILED;
|
do $GL_CONF_COMPILED;
|
||||||
add_repo_conf($repo) if $repo;
|
|
||||||
%cached_groups = %groups;
|
%cached_groups = %groups;
|
||||||
$cache_filled++;
|
$cache_filled++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# "who created this repo", "am I on the R list", and "am I on the RW list"?
|
||||||
|
sub wild_repo_rights
|
||||||
|
{
|
||||||
|
# set default categories
|
||||||
|
$GL_WILDREPOS_PERM_CATS ||= "READERS WRITERS";
|
||||||
|
my ($repo, $user) = @_;
|
||||||
|
|
||||||
# creator
|
# creator
|
||||||
my $c = '';
|
my $c = '';
|
||||||
if ( -f "$ENV{GL_REPO_BASE_ABS}/$repo.git/gl-creater") {
|
if ( -f "$ENV{GL_REPO_BASE_ABS}/$repo.git/gl-creater") {
|
||||||
|
@ -360,6 +362,7 @@ sub new_repo
|
||||||
# file). We replace each @foo with $user if $cached_groups{'@foo'}{$user}
|
# file). We replace each @foo with $user if $cached_groups{'@foo'}{$user}
|
||||||
# exists (i.e., $user is a member of @foo)
|
# exists (i.e., $user is a member of @foo)
|
||||||
for my $g ($perms =~ /\s(\@\S+)/g) {
|
for my $g ($perms =~ /\s(\@\S+)/g) {
|
||||||
|
fill_cache(); # get %cached_groups
|
||||||
$perms =~ s/ $g(?!\S)/ $user/ if $cached_groups{$g}{$user};
|
$perms =~ s/ $g(?!\S)/ $user/ if $cached_groups{$g}{$user};
|
||||||
}
|
}
|
||||||
# now setup the perm_cats hash to be returned
|
# now setup the perm_cats hash to be returned
|
||||||
|
|
Loading…
Reference in a new issue