Changeset 31513
- Timestamp:
- 2017-03-14T15:30:24+13:00 (7 years ago)
- Location:
- main/trunk/greenstone2/perllib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/servercontrol.pm
r31507 r31513 140 140 141 141 my $wget_file_path = &FileUtils::filenameConcatenate($ENV{'GSDLHOME'}, "bin", $ENV{'GSDLOS'}, "wget"); 142 my $tmpfilename = time . ".html"; # random name for file wherein we'll store the HTML page retrieved by wget 143 142 my $tmpfilename = &util::get_tmp_filename(".html", 1); # random file name with html extension in timestamped-tmpdir location (2nd param=1) 143 # wherein we'll store the HTML page retrieved by wget 144 144 145 # https://www.gnu.org/software/wget/manual/wget.html 145 146 # output-document set to - (STDOUT), so page is streamed to STDOUT … … 181 182 # server not running 182 183 $self->print_msg("*** Server not running. $library_url$command\n", 3); 184 &util::rm_tmp_file($tmpfilename); # will also remove any randomly named tmp directories containing the file 183 185 return 0; 184 186 } … … 195 197 sysread(FIN, $resultstr, -s FIN); 196 198 close(FIN); 197 &FileUtils::removeFiles("$tmpfilename"); 199 &util::rm_tmp_file($tmpfilename); # will also remove any randomly named tmp directories containing the file 200 198 201 199 202 #$resultstr =~ s@.*gs_content\"\>@@s; ## only true for default library servlet -
main/trunk/greenstone2/perllib/util.pm
r31475 r31513 276 276 { 277 277 my $file_ext = shift(@_) || undef; 278 my $use_timestamped_tmp_dir = shift(@_) || 0; # else defaults to using super directory named "tmp" 278 279 279 280 my $opt_dot_file_ext = ""; … … 290 291 } 291 292 292 my $tmpdir = &util::determine_tmp_dir(0);293 my $tmpdir = $use_timestamped_tmp_dir ? &util::get_timestamped_tmp_folder() : &util::determine_tmp_dir(0); 293 294 294 295 my $count = 1000; … … 340 341 341 342 return $tmp_dirname; 342 }343 344 sub get_parent_folder345 {346 my ($path) = @_;347 my ($tailname, $dirname, $suffix)348 = &File::Basename::fileparse($path, "\\.[^\\.]+\$");349 350 return &FileUtils::sanitizePath($dirname);351 343 } 352 344 … … 397 389 } 398 390 391 sub rm_tmp_file 392 { 393 my $tmpfilename = shift(@_); 394 395 my $tmpdir = &util::get_parent_folder($tmpfilename); 396 397 &FileUtils::removeFiles($tmpfilename); 398 # if the containing folder is a randomly named temporary subdirectory, remove it 399 # but not if it is the temporary "tmp" super directory itself. 400 if($tmpdir !~ m@^tmp(\\|\/)*$@) { 401 &FileUtils::removeFilesRecursive($tmpdir); 402 } 403 } 404 405 sub get_parent_folder 406 { 407 my ($path) = @_; 408 my ($tailname, $dirname, $suffix) 409 = &File::Basename::fileparse($path, "\\.[^\\.]+\$"); 410 411 return &FileUtils::sanitizePath($dirname); 412 } 399 413 400 414 sub filename_to_regex {
Note:
See TracChangeset
for help on using the changeset viewer.