[LON-CAPA-cvs] cvs: loncom /publisher londiff.pm lonpubdir.pm

www lon-capa-cvs@mail.lon-capa.org
Wed, 17 May 2006 13:41:46 -0000


www		Wed May 17 09:41:46 2006 EDT

  Modified files:              
    /loncom/publisher	londiff.pm lonpubdir.pm 
  Log:
  Bug #1431: if the file did not change, maintain the publication status
  
  
Index: loncom/publisher/londiff.pm
diff -u loncom/publisher/londiff.pm:1.18 loncom/publisher/londiff.pm:1.19
--- loncom/publisher/londiff.pm:1.18	Thu Apr  6 18:15:18 2006
+++ loncom/publisher/londiff.pm	Wed May 17 09:41:45 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to show differences between file versions
 #
-# $Id: londiff.pm,v 1.18 2006/04/06 22:15:18 albertel Exp $
+# $Id: londiff.pm,v 1.19 2006/05/17 13:41:45 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -32,6 +32,7 @@
 use strict;
 use Apache::File;
 use File::Copy;
+use File::Compare;
 use Algorithm::Diff qw(diff);
 use Apache::Constants qw(:common :http :methods);
 use Apache::loncacc;
@@ -44,7 +45,7 @@
     my ($fn,$style)=@_;
     my $f1;
     my @f1;
-    if ($style='local') {
+    if ($style eq 'local') {
 	if (-e $fn) {
 	    my $fh=Apache::File->new($fn);
 	    my $line;	
@@ -66,6 +67,11 @@
     return @f1;
 }
 
+sub are_different_files {
+    my ($fileone,$filetwo)=@_;
+    return &compare($fileone,$filetwo);
+}
+
 sub handler {
 
   my $r=shift;
@@ -124,7 +130,7 @@
 	 $r->print('<b>'.&mt('Construction Space Version').'</b>');
      } else {
 	 my $fn=
-	     '/home/httpd/html//res/'.$cudom.'/'.$cuname.'/';
+	     '/home/httpd/html/res/'.$cudom.'/'.$cuname.'/';
 	 if ($env{'form.versionone'}) {
 	     my ($main,$suffix)=($efn=~/^(.+)\.(\w+)$/);
 	     $fn.=$main.'.'.$env{'form.versionone'}.'.'.$suffix;
Index: loncom/publisher/lonpubdir.pm
diff -u loncom/publisher/lonpubdir.pm:1.90 loncom/publisher/lonpubdir.pm:1.91
--- loncom/publisher/lonpubdir.pm:1.90	Tue Apr 18 18:38:08 2006
+++ loncom/publisher/lonpubdir.pm	Wed May 17 09:41:45 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Construction Space Directory Lister
 #
-# $Id: lonpubdir.pm,v 1.90 2006/04/18 22:38:08 albertel Exp $
+# $Id: lonpubdir.pm,v 1.91 2006/05/17 13:41:45 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -36,6 +36,7 @@
 use Apache::loncacc;
 use Apache::loncommon();
 use Apache::lonhtmlcommon();
+use Apache::londiff();
 use Apache::lonlocal;
 use Apache::lonmsg;
 use Apache::lonmenu;
@@ -571,12 +572,23 @@
 #	$uname.'/'.$thisdisfn.'/'.$filename.'">'.
 #	&mt('Delete').'</a>';
     if (-e $resdir.'/'.$filename) {
+        my $same=0;
 	my ($rdev,$rino,$rmode,$rnlink,
 	    $ruid,$rgid,$rrdev,$rsize,
 	    $ratime,$rmtime,$rctime,
 	    $rblksize,$rblocks)=stat($resdir.'/'.$filename);
+        if ($rmtime>=$cmtime) {
+           $same=1;
+        } else {
+           if (&Apache::londiff::are_different_files($resdir.'/'.$filename,
+	                                      '/home/'.$uname.'/public_html/'.$thisdisfn.'/'.$filename)) {
+              $same=0;
+           } else {
+              $same=1;
+           }
+        }
 	$publish_button=&mt('Re-publish');
-	if ($rmtime>=$cmtime) {
+	if ($same) {
             $pubstatus = 'published';
 	    $status=&mt('Published').'<br />'.
 		&mt(&getCopyRightString($targetdir.'/'.$filename)).' '.