Project

General

Profile

« Previous | Next » 

Revision 7817

use File::Temp to write data files in registry. https://projects.ecoinformatics.org/ecoinfo/issues/6007

View differences:

src/perl/register-dataset.cgi
41 41
use Digest::SHA1;
42 42
use File::stat;
43 43
use File::Basename;
44
use File::Temp;
44 45
use strict;
45 46

  
46 47
#debug("running register-dataset.cgi");
......
1286 1287
	$ctx->add($fileData);
1287 1288
	my $digest = $ctx->hexdigest;
1288 1289

  
1289
	my $outputName = $tempDir . "/" . $cleanName;
1290
	open( OUT, ">$outputName" ) or die "Could not open: $!";
1291
	print OUT $fileData;
1292
	close(OUT);
1290
	# use tempfile for writing
1291
	my $tmp = File::Temp->new( 
1292
						TEMPLATE => 'tempXXXXX',
1293
                        DIR => '$tempDir',
1294
                        SUFFIX => $cleanName);
1295
	my $outputName = $tmp->filename();
1296
	#open( OUT, ">$outputName" ) or die "Could not open: $!";
1297
	print $tmp $fileData;
1298
	close($tmp);
1293 1299
	debug("Writing output, result is: $outputName");
1294 1300

  
1295 1301
	return ( $outputName, $digest );

Also available in: Unified diff