[LON-CAPA-cvs] cvs: loncom /debugging_tools check_authoring_spaces.pl

raeburn raeburn at source.lon-capa.org
Tue Oct 10 11:07:45 EDT 2017


raeburn		Tue Oct 10 15:07:45 2017 EDT

  Modified files:              
    /loncom/debugging_tools	check_authoring_spaces.pl 
  Log:
  - Display total number of files checked and total number of files copied.
  
  
Index: loncom/debugging_tools/check_authoring_spaces.pl
diff -u loncom/debugging_tools/check_authoring_spaces.pl:1.1 loncom/debugging_tools/check_authoring_spaces.pl:1.2
--- loncom/debugging_tools/check_authoring_spaces.pl:1.1	Mon Oct  9 22:17:05 2017
+++ loncom/debugging_tools/check_authoring_spaces.pl	Tue Oct 10 15:07:45 2017
@@ -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 @@
         }
     }
 
-    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 @@
                                                     $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 @@
                                 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 @@
     } 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 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 @@
                 } 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 @@
                         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;




More information about the LON-CAPA-cvs mailing list