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

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 26 Aug 2005 19:40:42 -0000


albertel		Fri Aug 26 15:40:42 2005 EDT

  Modified files:              
    /loncom/interface	portfolio.pm 
    /loncom	lond 
  Log:
  - BUG#4292, quota calculation was incorrect
  
  
Index: loncom/interface/portfolio.pm
diff -u loncom/interface/portfolio.pm:1.85 loncom/interface/portfolio.pm:1.86
--- loncom/interface/portfolio.pm:1.85	Mon May  2 15:08:16 2005
+++ loncom/interface/portfolio.pm	Fri Aug 26 15:40:38 2005
@@ -418,8 +418,8 @@
         }
     }
     my $current_disk_usage = &Apache::lonnet::diskusage($env{'user.domain'}, $env{'user.name'},$portfolio_root);
-    if ((($current_disk_usage/1000) + $filesize) > $disk_quota){
-        $r->print('<font color="red">Unable to upload <strong>'.$fname.' (size = '.$filesize.' kilobytes</strong>. Disk quota will be exceeded.'.
+    if ((($current_disk_usage) + $filesize/1000) > $disk_quota){
+        $r->print('<font color="red">Unable to upload <strong>'.$fname.' (size = '.$filesize.' kilobytes)</strong>. Disk quota will be exceeded.'.
                   '<br />Disk quota is '.$disk_quota.' kilobytes. Your current disk usage is '.$current_disk_usage.' kilobytes.');
         $r->print(&done('Back'));
     } 
Index: loncom/lond
diff -u loncom/lond:1.291 loncom/lond:1.292
--- loncom/lond:1.291	Tue Jul 12 17:29:58 2005
+++ loncom/lond	Fri Aug 26 15:40:38 2005
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # lond "LON Daemon" Server (port "LOND" 5663)
 #
-# $Id: lond,v 1.291 2005/07/12 21:29:58 albertel Exp $
+# $Id: lond,v 1.292 2005/08/26 19:40:38 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -48,6 +48,7 @@
 use localenroll;
 use localstudentphoto;
 use File::Copy;
+use File::Find;
 use LONCAPA::ConfigFileEdit;
 use LONCAPA::lonlocal;
 use LONCAPA::lonssl;
@@ -58,7 +59,7 @@
 my $status='';
 my $lastlog='';
 
-my $VERSION='$Revision: 1.291 $'; #' stupid emacs
+my $VERSION='$Revision: 1.292 $'; #' stupid emacs
 my $remoteVERSION;
 my $currenthostid="default";
 my $currentdomainid;
@@ -1363,18 +1364,17 @@
     #  etc.
     #
     if (-d $ududir) {
-	#  And as Shakespeare would say to make
-	#  assurance double sure, 
-	# use execute_command to ensure that the command is not executed in
-	# a shell that can screw us up.
-        my $file_list =  execute_command("find $ududir -not -regex '.*\.[0-9]+\.[^\.]+' -not -name '*.meta' -print");
-	my $duout = execute_command("du -ks $file_list");
-	$duout=~s/[^\d]//g; #preserve only the numbers
-	&Reply($client,"$duout\n","$cmd:$ududir");
+	my $total_size=0;
+	my $code=sub { 
+	    if ($_=~/\.\d+\./) { return;} 
+	    if ($_=~/\.meta$/) { return;}
+	    $total_size+=(stat($_))[7];
+	};
+	find($code,$ududir);
+	$total_size=int($total_size/1024);
+	&Reply($client,"$total_size\n","$cmd:$ududir");
     } else {
-
 	&Failure($client, "bad_directory:$ududir\n","$cmd:$ududir"); 
-
     }
     return 1;
 }