--- loncom/publisher/lonpublisher.pm 2023/07/14 22:19:22 1.303 +++ loncom/publisher/lonpublisher.pm 2024/06/01 22:25:23 1.304 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Publication Handler # -# $Id: lonpublisher.pm,v 1.303 2023/07/14 22:19:22 raeburn Exp $ +# $Id: lonpublisher.pm,v 1.304 2024/06/01 22:25:23 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -2129,11 +2129,7 @@ sub phasetwo { # ------------------------------------------------------------- Trigger updates push(@{$modified_urls},[$target,$source]); - unless ($registered_cleanup) { - my $handlers = $r->get_handlers('PerlCleanupHandler'); - $r->set_handlers('PerlCleanupHandler' => [\¬ify,@{$handlers}]); - $registered_cleanup=1; - } + ¬ify_in_cleanup($r); # ---------------------------------------------------------- Clear local caches my $thisdistarget=$target; @@ -2189,6 +2185,15 @@ sub phasetwo { } } +sub notify_in_cleanup { + my ($r) = @_; + unless ($registered_cleanup) { + my $handlers = $r->get_handlers('PerlCleanupHandler'); + $r->set_handlers('PerlCleanupHandler' => [\¬ify,@{$handlers}]); + $registered_cleanup=1; + } +} + # =============================================================== Notifications sub notify { # --------------------------------------------------- Send update notifications @@ -2350,6 +2355,9 @@ sub publishdirectory { my %commonaccess; map { $commonaccess{$_} = 1; } &Apache::loncommon::get_env_multiple('form.commonaccess'); unless ($lock) { $lock=&Apache::lonnet::set_lock(&mt('Publishing [_1]',$fn)); } + if ($lock) { + ¬ify_in_cleanup($r); + } # actually publish things opendir(DIR,$fn); my @files=sort(readdir(DIR)); @@ -2358,7 +2366,7 @@ sub publishdirectory { $cuid,$cgid,$crdev,$csize, $catime,$cmtime,$cctime, $cblksize,$cblocks)=stat($fn.'/'.$filename); - + my $extension=''; if ($filename=~/\.(\w+)$/) { $extension=$1; } if ($cmode&$dirptr) {