From d7112f2d4f7b60359aceb508f129f1065418d082 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Thu, 23 Apr 2015 09:55:13 -0700 Subject: [PATCH] Project.pm: create and maintain additional project info On project creation set receive.autogc and receive.updateserverinfo (false and true respectively). Also make sure the htmlcache subdirectory is created (and has the correct permissions) when the project itself is. Always create a 0-length info/lastactivity file with the correct permissions at project creation time. Finally, whenever project properties are saved touch htmlcache/changed. Signed-off-by: Kyle J. McKay --- Girocco/Project.pm | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Girocco/Project.pm b/Girocco/Project.pm index c5ece60..412d4c1 100644 --- a/Girocco/Project.pm +++ b/Girocco/Project.pm @@ -173,6 +173,7 @@ sub _properties_load { sub _properties_save { my $self = shift; + my $fd; foreach my $prop (keys %propmap) { $self->_property_fput($prop, $self->{$prop}); } @@ -182,11 +183,12 @@ sub _properties_save { "gitweb.statusupdates", $self->{statusupdates}); if (defined($self->{origurl}) && defined($self->{url}) && $self->{origurl} ne $self->{url} && -e $self->_property_path(".banged")) { - if (open(X, '>', $self->_property_path(".bangagain"))) { - close X; + if (open($fd, '>', $self->_property_path(".bangagain"))) { + close $fd; chmod(0664, $self->_property_path(".bangagain")); } } + open $fd, '>', "$self->{path}/htmlcache/changed" and close $fd; } sub _nofetch_path { @@ -579,6 +581,7 @@ sub _setup { use POSIX qw(strftime); my $self = shift; my ($pushers) = @_; + my $fd; $self->_mkdir_forkees; @@ -598,12 +601,22 @@ sub _setup { or die "disabling receive.denyNonFastforwards failed: $?"; system($Girocco::Config::git_bin, '--git-dir='.$self->{path}, 'config', 'gc.auto', '0') == 0 or die "disabling gc.auto failed: $?"; + system($Girocco::Config::git_bin, '--git-dir='.$self->{path}, 'config', 'receive.autogc', '0') == 0 + or die "disabling receive.autogc failed: $?"; my ($S,$M,$H,$d,$m,$y) = gmtime(time()); $self->{creationtime} = strftime("%Y-%m-%dT%H:%M:%SZ", $S, $M, $H, $d, $m, $y, -1, -1, -1); system($Girocco::Config::git_bin, '--git-dir='.$self->{path}, 'config', 'girocco.creationtime', $self->{creationtime}) == 0 or die "setting girocco.creationtime failed: $?"; + system($Girocco::Config::git_bin, '--git-dir='.$self->{path}, 'config', 'receive.updateserverinfo', 'true') == 0 + or die "enabling receive.updateserverinfo failed: $?"; system($Girocco::Config::git_bin, '--git-dir='.$self->{path}, 'config', 'repack.writebitmaps', 'true') == 0 or die "enabling repack.writebitmaps failed: $?"; + -d $self->{path}."/htmlcache" or mkdir $self->{path}."/htmlcache" + or die "htmlcache directory does not exist and unable to create it: $!"; + if (open $fd, '>', $self->{path}."/info/lastactivity") { + close $fd; + chmod 0664, $self->{path}."/info/lastactivity"; + } # /info must have right permissions, # and git init didn't do it for some reason. @@ -611,9 +624,11 @@ sub _setup { # and Git 2.1.0 - 2.2.1 incorrectly add +x for some reason. if ($Girocco::Config::owning_group) { chmod(02775, $self->{path}."/info") or die "chmod 02775 $self->{path}/info failed: $!"; + chmod(02775, $self->{path}."/htmlcache") or die "chmod 02775 $self->{path}/htmlcache failed: $!"; chmod(0664, $self->{path}."/config") or die "chmod 0664 $self->{path}/config failed: $!"; } else { chmod(02777, $self->{path}."/info") or die "chmod 02777 $self->{path}/info failed: $!"; + chmod(02777, $self->{path}."/htmlcache") or die "chmod 02777 $self->{path}/htmlcache failed: $!"; chmod(0666, $self->{path}."/config") or die "chmod 0666 $self->{path}/config failed: $!"; } -- 2.11.4.GIT