[LON-CAPA-cvs] cvs: loncom /lonnet/perl lonnet.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Fri, 18 Mar 2005 19:28:20 -0000
albertel Fri Mar 18 14:28:20 2005 EDT
Modified files:
/loncom/lonnet/perl lonnet.pm
Log:
- uploaded file_permissions wasn't checking dump/get's return for errors
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.612 loncom/lonnet/perl/lonnet.pm:1.613
--- loncom/lonnet/perl/lonnet.pm:1.612 Thu Mar 17 16:18:12 2005
+++ loncom/lonnet/perl/lonnet.pm Fri Mar 18 14:28:20 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.612 2005/03/17 21:18:12 albertel Exp $
+# $Id: lonnet.pm,v 1.613 2005/03/18 19:28:20 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1293,7 +1293,6 @@
}
# Notify homeserver to grep it
#
- &Apache::lonnet::logthis("fetching ".$path.$file);
my $fetchresult= &reply('fetchuserfile:'.$path.$file,$docuhome);
if ($fetchresult eq 'ok') {
#
@@ -1309,7 +1308,7 @@
sub removeuploadedurl {
my ($url)=@_;
my (undef,undef,$udom,$uname,$fname)=split('/',$url,5);
- return &Apache::lonnet::removeuserfile($uname,$udom,$fname);
+ return &removeuserfile($uname,$udom,$fname);
}
sub removeuserfile {
@@ -3716,8 +3715,11 @@
my @check;
my $is_locked;
push @check, $file_name;
- my %locked = &Apache::lonnet::get('file_permissions',\@check,
- $ENV{'user.domain'},$ENV{'user.name'});
+ my %locked = &get('file_permissions',\@check,
+ $ENV{'user.domain'},$ENV{'user.name'});
+ my ($tmp)=keys(%locked);
+ if ($tmp=~/^error:/) { undef(%locked); }
+
if (ref($locked{$file_name}) eq 'ARRAY') {
$is_locked = 'true';
} else {
@@ -3729,11 +3731,14 @@
sub mark_as_readonly {
my ($domain,$user,$files,$what) = @_;
- my %current_permissions = &Apache::lonnet::dump('file_permissions',$domain,$user);
+ my %current_permissions = &dump('file_permissions',$domain,$user);
+ my ($tmp)=keys(%current_permissions);
+ if ($tmp=~/^error:/) { undef(%current_permissions); }
+
foreach my $file (@{$files}) {
push(@{$current_permissions{$file}},$what);
}
- &Apache::lonnet::put('file_permissions',\%current_permissions,$domain,$user);
+ &put('file_permissions',\%current_permissions,$domain,$user);
return;
}
@@ -3810,7 +3815,10 @@
sub get_marked_as_readonly {
my ($domain,$user,$what) = @_;
- my %current_permissions = &Apache::lonnet::dump('file_permissions',$domain,$user);
+ my %current_permissions = &dump('file_permissions',$domain,$user);
+ my ($tmp)=keys(%current_permissions);
+ if ($tmp=~/^error:/) { undef(%current_permissions); }
+
my @readonly_files;
while (my ($file_name,$value) = each(%current_permissions)) {
if (ref($value) eq "ARRAY"){
@@ -3829,7 +3837,10 @@
sub get_marked_as_readonly_hash {
my ($domain,$user,$what) = @_;
- my %current_permissions = &Apache::lonnet::dump('file_permissions',$domain,$user);
+ my %current_permissions = &dump('file_permissions',$domain,$user);
+ my ($tmp)=keys(%current_permissions);
+ if ($tmp=~/^error:/) { undef(%current_permissions); }
+
my %readonly_files;
while (my ($file_name,$value) = each(%current_permissions)) {
if (ref($value) eq "ARRAY"){
@@ -3850,8 +3861,11 @@
# unmarks all files locked by $what
# for portfolio submissions, $what contains $crsid and $symb
my ($domain,$user,$what) = @_;
- my %current_permissions = &Apache::lonnet::dump('file_permissions',$domain,$user);
- my @readonly_files = &Apache::lonnet::get_marked_as_readonly($domain,$user,$what);
+ my %current_permissions = &dump('file_permissions',$domain,$user);
+ my ($tmp)=keys(%current_permissions);
+ if ($tmp=~/^error:/) { undef(%current_permissions); }
+
+ my @readonly_files = &get_marked_as_readonly($domain,$user,$what);
foreach my $file(@readonly_files){
my $current_locks = $current_permissions{$file};
my @new_locks;
@@ -3866,12 +3880,12 @@
$current_permissions{$file} = \@new_locks;
} else {
push(@del_keys, $file);
- &Apache::lonnet::del('file_permissions',\@del_keys, $domain, $user);
+ &del('file_permissions',\@del_keys, $domain, $user);
delete $current_permissions{$file};
}
}
}
- &Apache::lonnet::put('file_permissions',\%current_permissions,$domain,$user);
+ &put('file_permissions',\%current_permissions,$domain,$user);
return;
}
@@ -4470,7 +4484,7 @@
} else {
$metaentry{':packages'}=$package.$keyroot;
}
- foreach (keys %packagetab) {
+ foreach (sort keys %packagetab) {
my $part=$keyroot;
$part=~s/^\_//;
if ($_=~/^\Q$package\E\&/ ||
@@ -4687,7 +4701,7 @@
if (!$title) { $title=(split('/',$urlsymb))[-1]; }
return $title;
}
-
+
# ------------------------------------------------- Update symbolic store links
sub symblist {