[LON-CAPA-cvs] cvs: loncom / lond
foxr
lon-capa-cvs@mail.lon-capa.org
Wed, 18 Aug 2004 11:31:50 -0000
foxr Wed Aug 18 07:31:50 2004 EDT
Modified files:
/loncom lond
Log:
Fix error in fetch_user_file_handler that was not sticking uploaded files
where they belonged.
Index: loncom/lond
diff -u loncom/lond:1.231 loncom/lond:1.232
--- loncom/lond:1.231 Tue Aug 17 06:44:00 2004
+++ loncom/lond Wed Aug 18 07:31:50 2004
@@ -2,7 +2,7 @@
# The LearningOnline Network
# lond "LON Daemon" Server (port "LOND" 5663)
#
-# $Id: lond,v 1.231 2004/08/17 10:44:00 foxr Exp $
+# $Id: lond,v 1.232 2004/08/18 11:31:50 foxr Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -52,12 +52,12 @@
use LONCAPA::lonssl;
use Fcntl qw(:flock);
-my $DEBUG = 0; # Non zero to enable debug log entries.
+my $DEBUG = 1; # Non zero to enable debug log entries.
my $status='';
my $lastlog='';
-my $VERSION='$Revision: 1.231 $'; #' stupid emacs
+my $VERSION='$Revision: 1.232 $'; #' stupid emacs
my $remoteVERSION;
my $currenthostid="default";
my $currentdomainid;
@@ -1756,18 +1756,39 @@
my $userinput = "$cmd:$tail";
my $fname = $tail;
- my ($udom,$uname,$ufile)=split(/\//,$fname);
+ my ($udom,$uname,$ufile) = ($fname =~ m|^([^/]+)/([^/]+)/(.+)$|);
my $udir=&propath($udom,$uname).'/userfiles';
unless (-e $udir) {
mkdir($udir,0770);
}
+ Debug("fetch user file for $fname");
if (-e $udir) {
$ufile=~s/^[\.\~]+//;
- $ufile=~s/\///g;
+
+ # IF necessary, create the path right down to the file.
+ # Note that any regular files in the way of this path are
+ # wiped out to deal with some earlier folly of mine.
+
+ my $path = $udir;
+ if ($ufile =~m|(.+)/([^/]+)$|) {
+ my @parts=split('/',$1);
+ foreach my $part (@parts) {
+ $path .= '/'.$part;
+ if( -f $path) {
+ unlink($path);
+ }
+ if ((-e $path)!=1) {
+ mkdir($path,0770);
+ }
+ }
+ }
+
+
my $destname=$udir.'/'.$ufile;
my $transname=$udir.'/'.$ufile.'.in.transit';
my $remoteurl='http://'.$clientip.'/userfiles/'.$fname;
my $response;
+ Debug("Remote URL : $remoteurl Transfername $transname Destname: $destname");
alarm(120);
{
my $ua=new LWP::UserAgent;
@@ -1781,6 +1802,7 @@
&logthis("LWP GET: $message for $fname ($remoteurl)");
&Failure($client, "failed\n", $userinput);
} else {
+ Debug("Renaming $transname to $destname");
if (!rename($transname,$destname)) {
&logthis("Unable to move $transname to $destname");
unlink($transname);