[LON-CAPA-cvs] cvs: loncom /interface lonindexer.pm

albertel lon-capa-cvs@mail.lon-capa.org
Mon, 26 Jul 2004 22:38:17 -0000


albertel		Mon Jul 26 18:38:17 2004 EDT

  Modified files:              
    /loncom/interface	lonindexer.pm 
  Log:
  - timestamp the remebered dirlistings  and ignore them after 10 minutes
  
  
Index: loncom/interface/lonindexer.pm
diff -u loncom/interface/lonindexer.pm:1.120 loncom/interface/lonindexer.pm:1.121
--- loncom/interface/lonindexer.pm:1.120	Thu Jul 15 10:47:31 2004
+++ loncom/interface/lonindexer.pm	Mon Jul 26 18:38:16 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Directory Indexer
 #
-# $Id: lonindexer.pm,v 1.120 2004/07/15 14:47:31 matthew Exp $
+# $Id: lonindexer.pm,v 1.121 2004/07/26 22:38:16 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -662,10 +662,13 @@
     if ($ENV{'form.updatedisplay'}) {
 	foreach (keys %hash) {
 	    delete $hash{$_} if ($_ =~ /^dirlist_files_/);
+	    delete $hash{$_} if ($_ =~ /^dirlist_timestamp_files_/);
 	}
     }
 
-    if ($hash{'dirlist_files_'.$luri}) {
+    if (defined($hash{'dirlist_files_'.$luri}) &&
+	$hash{'dirlist_timestamp_files_'.$luri}+600 > (time)) {
+	&Apache::lonnet::logthis("using old n:".time." s:".$hash{'dirlist_timestamp_files_'.$luri});
 	@list = split(/\n/,$hash{'dirlist_files_'.$luri});
     } elsif ($uri=~/\.(page|sequence)\/$/) {
 # is a page or a sequence
@@ -679,8 +682,10 @@
 	$hash{'dirlist_files_'.$luri} = join("\n",@list);
     } else {
 # is really a directory
+	&Apache::lonnet::logthis("getting fresh n:".time." s:".$hash{'dirlist_timestamp_files_'.$luri});
 	@list = &Apache::lonnet::dirlist($uri);
 	$hash{'dirlist_files_'.$luri} = join("\n",@list);
+	$hash{'dirlist_timestamp_files_'.$luri} = time;
     }
     return @list=&match_ext($r,@list);
 }