[LON-CAPA-cvs] cvs: loncom /lonnet/perl lonrep.pm lonuploadrep.pm

albertel lon-capa-cvs@mail.lon-capa.org
Mon, 21 Aug 2006 15:21:33 -0000


albertel		Mon Aug 21 11:21:33 2006 EDT

  Modified files:              
    /loncom/lonnet/perl	lonrep.pm lonuploadrep.pm 
  Log:
  - Apache2 caches finfo and needs finfo explicitly updated if one is touching
    $r->filename after the PerlMapToStorageHandler phase
  
  
Index: loncom/lonnet/perl/lonrep.pm
diff -u loncom/lonnet/perl/lonrep.pm:1.10 loncom/lonnet/perl/lonrep.pm:1.11
--- loncom/lonnet/perl/lonrep.pm:1.10	Wed Aug 31 04:13:52 2005
+++ loncom/lonnet/perl/lonrep.pm	Mon Aug 21 11:21:31 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Replication Manager
 #
-# $Id: lonrep.pm,v 1.10 2005/08/31 08:13:52 albertel Exp $
+# $Id: lonrep.pm,v 1.11 2006/08/21 15:21:31 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -34,6 +34,19 @@
 use Apache::File();
 use CGI::Cookie();
 
+sub update_filename {
+    my ($r,$filename) = @_;
+    my $oldfile = $r->filename($filename);
+    if ($ENV{'MOD_PERL_API_VERSION'} == 2) {
+	require APR::Finfo;
+	require APR::Const;
+	$r->finfo(APR::Finfo::stat($filename, 
+				   &APR::Const::FINFO_NORM(),
+				   $r->pool));
+    }
+    return $oldfile;
+}
+
 sub handler {
     my $r = shift;
     if (-e $r->finfo) {
@@ -43,7 +56,7 @@
       if ($filename=~/\/$/) { return OK; }
       if (-e "$filename.in.transfer") {
 	sleep 10;
-        $r->filename($filename);
+	&update_filename($r,$filename);
         if (-e $r->finfo) {
 	   return OK;
         } else {
@@ -54,7 +67,7 @@
           my $response=Apache::lonnet::repcopy($filename);
           if ($response eq 'ok') {
 	      $r->path_info('');
-	      $r->filename($filename);
+	      &update_filename($r,$filename);
               return OK;
           }
           my %cookies=CGI::Cookie->parse($r->header_in('Cookie'));
Index: loncom/lonnet/perl/lonuploadrep.pm
diff -u loncom/lonnet/perl/lonuploadrep.pm:1.7 loncom/lonnet/perl/lonuploadrep.pm:1.8
--- loncom/lonnet/perl/lonuploadrep.pm:1.7	Thu Apr  7 02:56:24 2005
+++ loncom/lonnet/perl/lonuploadrep.pm	Mon Aug 21 11:21:31 2006
@@ -28,6 +28,7 @@
 
 use strict;
 use Apache::Constants qw(:common :http);
+use Apache::lonrep();
 use Apache::lonnet;
 use CGI::Cookie();
 
@@ -46,14 +47,14 @@
             } elsif ( ($info > 0) && ($info =~ /\d+/) )  {
                 my @statinfo = stat($filename); 
                 if ($statinfo[9] >= $info ) {
-                    $r->filename($filename);
+                    &Apache::lonrep::update_filename($r,$filename);
                     return OK;
                 }
             }
         }
         my $response=&Apache::lonnet::repcopy_userfile($r->uri);
         if ($response eq 'ok') {
-            $r->filename($filename);
+	    &Apache::lonrep::update_filename($r,$filename);
             return OK;
         }
     }