[LON-CAPA-cvs] cvs: loncom / lond

www www@source.lon-capa.org
Thu, 03 Dec 2009 17:43:19 -0000


www		Thu Dec  3 17:43:19 2009 EDT

  Modified files:              
    /loncom	lond 
  Log:
  Bug #6139: remove tmp-preview of replicated resources. UNTESTED. Need to
  test on library-access-server setup!
  
  
Index: loncom/lond
diff -u loncom/lond:1.433 loncom/lond:1.434
--- loncom/lond:1.433	Thu Nov 12 15:59:00 2009
+++ loncom/lond	Thu Dec  3 17:43:19 2009
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # lond "LON Daemon" Server (port "LOND" 5663)
 #
-# $Id: lond,v 1.433 2009/11/12 15:59:00 raeburn Exp $
+# $Id: lond,v 1.434 2009/12/03 17:43:19 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -59,7 +59,7 @@
 my $status='';
 my $lastlog='';
 
-my $VERSION='$Revision: 1.433 $'; #' stupid emacs
+my $VERSION='$Revision: 1.434 $'; #' stupid emacs
 my $remoteVERSION;
 my $currenthostid="default";
 my $currentdomainid;
@@ -2062,16 +2062,10 @@
 &register_handler("home", \&is_home_handler, 0,1,0);
 
 #
-#   Process an update request for a resource?? I think what's going on here is
-#   that a resource has been modified that we hold a subscription to.
+#   Process an update request for a resource.
+#   A resource has been modified that we hold a subscription to.
 #   If the resource is not local, then we must update, or at least invalidate our
 #   cached copy of the resource. 
-#   FUTURE WORK:
-#      I need to look at this logic carefully.  My druthers would be to follow
-#      typical caching logic, and simple invalidate the cache, drop any subscription
-#      an let the next fetch start the ball rolling again... however that may
-#      actually be more difficult than it looks given the complex web of
-#      proxy servers.
 # Parameters:
 #    $cmd      - The command that got us here.
 #    $tail     - Tail of the command (remaining parameters).
@@ -2095,16 +2089,23 @@
     my $ownership=ishome($fname);
     if ($ownership eq 'not_owner') {
 	if (-e $fname) {
+            # Delete preview file, if exists
+            unlink("$fname.tmp");
+            # Get usage stats
 	    my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
 		$atime,$mtime,$ctime,$blksize,$blocks)=stat($fname);
 	    my $now=time;
 	    my $since=$now-$atime;
+            # If the file has not been used within lonExpire seconds,
+            # unsubscribe from it and delete local copy
 	    if ($since>$perlvar{'lonExpire'}) {
 		my $reply=&Apache::lonnet::reply("unsub:$fname","$clientname");
 		&devalidate_meta_cache($fname);
 		unlink("$fname");
 		unlink("$fname.meta");
 	    } else {
+            # Yes, this is in active use. Get a fresh copy. Since it might be in
+            # very active use and huge (like a movie), copy it to "in.transfer" filename first.
 		my $transname="$fname.in.transfer";
 		my $remoteurl=&Apache::lonnet::reply("sub:$fname","$clientname");
 		my $response;
@@ -2132,6 +2133,7 @@
 			}
 			alarm(0);
 		    }
+                    # we successfully transfered, copy file over to real name
 		    rename($transname,$fname);
 		    &devalidate_meta_cache($fname);
 		}