--- loncom/publisher/loncfile.pm 2002/11/27 17:05:50 1.20 +++ loncom/publisher/loncfile.pm 2003/01/09 22:11:52 1.21 @@ -10,7 +10,7 @@ # # -# $Id: loncfile.pm,v 1.20 2002/11/27 17:05:50 albertel Exp $ +# $Id: loncfile.pm,v 1.21 2003/01/09 22:11:52 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -323,20 +323,24 @@ sub exists { my ($user, $domain, $dir, $file) = @_; # Create complete paths in publication and construction space. - - my $published = &PublicationPath($domain, $user, $dir, $file); - my $construct = &ConstructionPath($user, $dir, $file); + my $relativedir=$dir; + $relativedir=s|/home/\Q$user\E/public_html||; + my $published = &PublicationPath($domain, $user, $relativedir, $file); + my $construct = &ConstructionPath($user, $relativedir, $file); # If the resource exists in either space indicate this fact. # Note that the check for existence in resource space is stricter. my $result; + if ( -d $construct ) { + return 'Error: destination for operation is a directory.'; + } if ( -e $published) { - $result.='

Warning: target file exists, and has been published!

'; + $result.='

Warning: target file exists, and has been published!

'; } elsif ( -e $construct) { - $result.='

Warning: target file exists!

'; - } + $result.='

Warning: target file exists!

'; + } return $result; @@ -492,7 +496,12 @@ sub Rename1 { if($ENV{'form.newfilename'}) { my $newfilename = $ENV{'form.newfilename'}; $request->print(&checksuffix($filename, $newfilename)); - $request->print(&exists($user, $domain, $dir, $newfilename)); + my $return=&exists($user, $domain, $dir, $newfilename); + $request->print($return); + if ($return =~/^Error:/) { + $request->print('
Cancel'); + return; + } my $dest=&SimplifyDir($dir,$newfilename); $request->print('Cancel'); + return; + } my $dest=&SimplifyDir($dir,$newfilename); $request->print('