--- loncom/debugging_tools/check_authoring_spaces.pl 2017/10/09 22:17:05 1.1 +++ loncom/debugging_tools/check_authoring_spaces.pl 2017/10/10 15:07:45 1.2 @@ -9,7 +9,7 @@ # If files are not the same include in list for potentially overwriting # file in Authoring space with file in Resource space. # -# $Id: check_authoring_spaces.pl,v 1.1 2017/10/09 22:17:05 raeburn Exp $ +# $Id: check_authoring_spaces.pl,v 1.2 2017/10/10 15:07:45 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -326,14 +326,15 @@ if ($action eq 'undo') { } } - my %allcopied; + my (%allcopied,$numcopied,$numchecked); # Iterate over directories in /home/httpd/html/res + $numchecked = 0; foreach my $uname (sort(keys(%pubusers))) { if (ref($pubusers{$uname}) eq 'ARRAY') { foreach my $dom (@{$pubusers{$uname}}) { my %allfiles; - &descend_res_tree('',$londocroot,$dom,$uname,\%allfiles); + &descend_res_tree('',$londocroot,$dom,$uname,\%allfiles,\$numchecked); if (keys(%allfiles)) { print &mt('User: [_1], in domain: [_2] has [quant,_3,file].',$uname,$dom,scalar(keys(%allfiles)))."\n". &mt('Continue? ~[y/N~] '); @@ -416,6 +417,7 @@ if ($action eq 'undo') { $output .= &mt('Copied [_1] to [_2].', "'$source_path'","'$target_path'")."\n"; push(@{$allcopied{$dom}{$uname}},$key); + $numcopied ++; my $logfile; my $logname = $target_path.'.log'; if (-e $logname) { @@ -452,6 +454,7 @@ if ($action eq 'undo') { print $logfh $output; } elsif ($action eq 'dryrun') { push(@{$allcopied{$dom}{$uname}},$key); + $numcopied ++; print &mt('Would copy [_1] to [_2].',"'$source_path'","'$target_path'")."\n"; } } @@ -467,8 +470,8 @@ if ($action eq 'undo') { } else { foreach my $dom (sort(keys(%allcopied))) { if (ref($allcopied{$dom}) eq 'HASH') { - $copyinfo .= "\n ".&mt('Domain: [_1], number of authors: [_2]', - "'$dom'",scalar(keys(%{$allcopied{$dom}}))); + $copyinfo .= "\n ".&mt('Domain: [_1], number of authors: [_2], number for copying: [_3], total number of files checked: [_4]', + "'$dom'",scalar(keys(%{$allcopied{$dom}})),$numcopied,$numchecked); } } } @@ -534,7 +537,7 @@ sub stop_logging { } sub descend_res_tree { - my ($dir,$londocroot,$dom,$uname,$allfiles) = @_; + my ($dir,$londocroot,$dom,$uname,$allfiles,$numchecked) = @_; my $path = "$londocroot/res/$dom/$uname"; if ($dir ne '') { $path .= "/$dir"; @@ -551,7 +554,7 @@ sub descend_res_tree { } else { $newdir = $dir.'/'.$item; } - &descend_res_tree($newdir,$londocroot,$dom,$uname,$allfiles); + &descend_res_tree($newdir,$londocroot,$dom,$uname,$allfiles,$numchecked); } else { my $newpath; if ($dir eq '') { @@ -568,6 +571,9 @@ sub descend_res_tree { my $lastmodres = (stat($resfile))[9]; my $lastmodcstr = (stat($cstrfile))[9]; my $delta = $lastmodres - $lastmodcstr; + if (ref($numchecked)) { + $$numchecked ++; + } if ($delta > 0) { if (&File::Compare::compare($resfile,$cstrfile)) { $allfiles->{$newpath} = $delta;