--- loncom/interface/portfolio.pm 2004/09/06 23:59:05 1.37
+++ loncom/interface/portfolio.pm 2004/09/08 17:53:37 1.38
@@ -376,10 +376,13 @@ sub rename_confirmed {
sub upload {
my ($r)=@_;
my $fname=$ENV{'form.uploaddoc.filename'};
+ my $filesize = (length($ENV{'form.uploaddoc'})) / 1000; #express in k (1024?)
+ my $disk_quota = 20000; # expressed in k
$fname=&Apache::lonnet::clean_filename($fname);
my $portfolio_root = &Apache::loncommon::propath($ENV{'user.domain'},
$ENV{'user.name'}).
'/userfiles/portfolio';
+ # Fixme --- Move the checking for existing file to LOND error return
my @dir_list=&Apache::lonnet::dirlist($ENV{'form.currentpath'},
$ENV{'user.domain'},
$ENV{'user.name'},$portfolio_root);
@@ -390,8 +393,12 @@ sub upload {
$found_file = 1;
}
}
- $r->print('
'.&Apache::lonnet::diskusage($ENV{'user.domain'}, $ENV{'user.name'},$portfolio_root).'
');
- if ($found_file){
+ my $current_disk_usage = &Apache::lonnet::diskusage($ENV{'user.domain'}, $ENV{'user.name'},$portfolio_root);
+ if (($current_disk_usage + $filesize) > $disk_quota){
+ $r->print('Unable to upload '.$fname.' (size = '.$filesize.' kilobytes. Disk quota will be exceeded.'.
+ '
Disk quota is '.$disk_quota.' kilobytes. Your current disk usage is '.$current_disk_usage.' kilobytes.');
+ }
+ elsif ($found_file){
$r->print('Unable to upload '.$fname.', a file by that name was found in '.$ENV{'form.currentpath'}.''.
'
To upload, rename or delete existing '.$fname.' in '.$ENV{'form.currentpath'});
} else {
@@ -461,6 +468,7 @@ sub handler {
['selectfile','currentpath',
'currentfile']);
# make sure there is a portfolio directory off /userfiles
+ # Fixme -- Do this in a better way -- offload it to the LOND routine
my @dir_list=&Apache::lonnet::dirlist('/',
$ENV{'user.domain'},
$ENV{'user.name'},$portfolio_root);
@@ -489,7 +497,7 @@ sub handler {
if ($ENV{'form.currentpath'}) {
$current_path = $ENV{'form.currentpath'};
}
- my @dir_list=&Apache::lonnet::dirlist($current_path,
+ @dir_list=&Apache::lonnet::dirlist($current_path,
$ENV{'user.domain'},
$ENV{'user.name'},$portfolio_root);