From 92ca3ed8341ef41550f7f652272de60b4758dc7e Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Mon, 27 Apr 2015 10:37:09 -0700 Subject: [PATCH] Project/tagproj: maintain caching status files Signed-off-by: Kyle J. McKay --- Girocco/Project.pm | 41 +++++++++++++++++++++++++++++++++++++++-- cgi/tagproj.cgi | 3 ++- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/Girocco/Project.pm b/Girocco/Project.pm index cd14872..502f2cd 100644 --- a/Girocco/Project.pm +++ b/Girocco/Project.pm @@ -188,7 +188,6 @@ sub _properties_save { chmod(0664, $self->_property_path(".bangagain")); } } - open $fd, '>', "$self->{path}/htmlcache/changed" and close $fd; } sub _nofetch_path { @@ -262,7 +261,20 @@ sub _alternates_setup { chmod 0664, $filename or warn "cannot chmod $filename: $!"; } + # copy lastactivity from the parent project + if (open $x, '<', $forkee_path.'/info/lastactivity') {{ + my $activity = <$x>; + close $x; + last unless $activity; + open $x, '>', $self->{path}.'/info/lastactivity' or last; + print $x $activity; + close $x; + chomp $activity; + $self->{'lastactivity'} = $activity; + }} + # copy refs from parent project + local *SAVEOUT; open(SAVEOUT, ">&STDOUT") || die "couldn't dup STDOUT: $!"; my $result = open(STDOUT, '>', "$self->{path}/packed-refs"); my $resultstr = $!; @@ -286,6 +298,26 @@ sub _alternates_setup { chmod 0664, "$self->{path}/packed-refs", "$self->{path}/HEAD"; } +sub _set_changed { + my $self = shift; + my $fd; + open $fd, '>', "$self->{path}/htmlcache/changed" and close $fd; +} + +sub _set_forkchange { + my $self = shift; + my $changedtoo = shift; + return unless $self->{name} =~ m#/#; + my $forkee_path = get_forkee_path($self->{name}); + return unless -d $forkee_path; + # mark forkee as changed + my $fd; + open $fd, '>', $forkee_path.'/htmlcache/changed' and close $fd if $changedtoo; + open $fd, '>', $forkee_path.'/htmlcache/forkchange' and close $fd; + return if -e $forkee_path.'/htmlcache/summary.forkchange'; + open $fd, '>', $forkee_path.'/htmlcache/summary.forkchange' and close $fd; +} + sub _ctags_setup { my $self = shift; my $perms = $Girocco::Config::permission_control eq 'Hooks' ? 02777 : 02775; @@ -665,8 +697,9 @@ sub _setup { $self->_group_remove; $self->_group_add($pushers); $self->_hooks_install; - #$self->perm_initialize; $self->_update_index; + $self->_set_changed; + $self->_set_forkchange(1); } sub premirror { @@ -724,6 +757,7 @@ sub update { $self->_update_index if $self->{email} ne $self->{orig_email}; $self->{orig_email} = $self->{email}; + $self->_set_changed; 1; } @@ -753,6 +787,9 @@ sub delete { } $self->_group_remove; $self->_update_index; + $self->_set_forkchange(1); + + 1; } sub _contains_files { diff --git a/cgi/tagproj.cgi b/cgi/tagproj.cgi index fb947b8..c90f2e2 100755 --- a/cgi/tagproj.cgi +++ b/cgi/tagproj.cgi @@ -55,7 +55,8 @@ foreach my $ctag (split(/ /, $ctags)) { my $oldmask = umask(); umask($oldmask & ~0060); open $ct, '>', $proj->{path}."/ctags/$ctag" and print $ct ($val+1)."\n" and close $ct; - open $ct, '>', $proj->{path}."/htmlcache/changed" and close $ct; + $proj->_set_changed; + $proj->_set_forkchange; umask($oldmask); } -- 2.11.4.GIT