[LON-CAPA-cvs] cvs: loncom(version_2_1_X) / lond

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 27 Jan 2006 23:05:32 -0000


albertel		Fri Jan 27 18:05:32 2006 EDT

  Modified files:              (Branch: version_2_1_X)
    /loncom	lond 
  Log:
  - backport 1.308
  
  
Index: loncom/lond
diff -u loncom/lond:1.305 loncom/lond:1.305.2.1
--- loncom/lond:1.305	Tue Jan 17 16:00:00 2006
+++ loncom/lond	Fri Jan 27 18:05:30 2006
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # lond "LON Daemon" Server (port "LOND" 5663)
 #
-# $Id: lond,v 1.305 2006/01/17 21:00:00 albertel Exp $
+# $Id: lond,v 1.305.2.1 2006/01/27 23:05:30 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -59,7 +59,7 @@
 my $status='';
 my $lastlog='';
 
-my $VERSION='$Revision: 1.305 $'; #' stupid emacs
+my $VERSION='$Revision: 1.305.2.1 $'; #' stupid emacs
 my $remoteVERSION;
 my $currenthostid="default";
 my $currentdomainid;
@@ -1943,6 +1943,7 @@
 	    my $since=$now-$atime;
 	    if ($since>$perlvar{'lonExpire'}) {
 		my $reply=&reply("unsub:$fname","$clientname");
+		&devalidate_meta_cache($fname);
 		unlink("$fname");
 	    } else {
 		my $transname="$fname.in.transfer";
@@ -1973,14 +1974,7 @@
 			alarm(0);
 		    }
 		    rename($transname,$fname);
-		    use Cache::Memcached;
-		    my $memcache=
-			new Cache::Memcached({'servers'=>['127.0.0.1:11211']});
-		    my $url=$fname;
-		    $url=~s-^/home/httpd/html--;
-		    $url=~s-\.meta$--;
-		    my $id=&escape('meta:'.$url);
-		    $memcache->delete($id);
+		    &devalidate_meta_cache($fname);
 		}
 	    }
 	    &Reply( $client, "ok\n", $userinput);
@@ -1994,6 +1988,26 @@
 }
 &register_handler("update", \&update_resource_handler, 0 ,1, 0);
 
+sub devalidate_meta_cache {
+    my ($url) = @_;
+    use Cache::Memcached;
+    my $memcache = new Cache::Memcached({'servers'=>['127.0.0.1:11211']});
+    $url = &declutter($url);
+    $url =~ s-\.meta$--;
+    my $id = &escape('meta:'.$url);
+    $memcache->delete($id);
+}
+
+sub declutter {
+    my $thisfn=shift;
+    $thisfn=~s/^\Q$perlvar{'lonDocRoot'}\E//;
+    $thisfn=~s/^\///;
+    $thisfn=~s|^adm/wrapper/||;
+    $thisfn=~s|^adm/coursedocs/showdoc/||;
+    $thisfn=~s/^res\///;
+    $thisfn=~s/\?.+$//;
+    return $thisfn;
+}
 #
 #   Fetch a user file from a remote server to the user's home directory
 #   userfiles subdir.