[LON-CAPA-cvs] cvs: loncom /lonnet/perl lonnet.pm

albertel lon-capa-cvs@mail.lon-capa.org
Wed, 18 Jan 2006 21:15:42 -0000


albertel		Wed Jan 18 16:15:42 2006 EDT

  Modified files:              
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - check if we can successfully create the temporary file before telling
     lond to grab it
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.700 loncom/lonnet/perl/lonnet.pm:1.701
--- loncom/lonnet/perl/lonnet.pm:1.700	Thu Jan 12 16:12:55 2006
+++ loncom/lonnet/perl/lonnet.pm	Wed Jan 18 16:15:41 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.700 2006/01/12 21:12:55 albertel Exp $
+# $Id: lonnet.pm,v 1.701 2006/01/18 21:15:41 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1358,8 +1358,16 @@
     }
 # Save the file
     {
-	open(FH,'>'.$filepath.'/'.$file);
-	print FH $env{'form.'.$formname};
+	if (!open(FH,'>'.$filepath.'/'.$file)) {
+	    &logthis('Failed to create '.$filepath.'/'.$file);
+	    print STDERR ('Failed to create '.$filepath.'/'.$file."\n");
+	    return '/adm/notfound.html';
+	}
+	if (!print FH ($env{'form.'.$formname})) {
+	    &logthis('Failed to write to '.$filepath.'/'.$file);
+	    print STDERR ('Failed to write to '.$filepath.'/'.$file."\n");
+	    return '/adm/notfound.html';
+	}
 	close(FH);
     }
     if ($parser eq 'parse') {