Diff for /loncom/debugging_tools/check_authoring_spaces.pl between versions 1.1 and 1.2

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

Removed from v.1.1  
changed lines
  Added in v.1.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>