Changeset 23177 for main/trunk/greenstone2/cgi-bin/talkback-progressbar.pl
- Timestamp:
- 2010-10-19T17:30:19+13:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/cgi-bin/talkback-progressbar.pl
r23149 r23177 1 1 #!/usr/bin/perl -w 2 3 2 4 3 use strict; … … 8 7 9 8 my $gsdl_cgi; 9 my $gsdl_home; 10 10 my $gsdl_tmp_dir; 11 12 my $debugging_enabled = 1; # if 1, debugging is enabled and deleting files will not happen 11 13 12 14 BEGIN { … … 167 169 # Useful debug to slow down a 'fast' upload 168 170 # Sleep for 10 msecs 169 select(undef, undef, undef, 0.01);171 # select(undef, undef, undef, 0.01); 170 172 #select(undef, undef, undef, 0.1); 171 173 } … … 202 204 my $progress_filename = get_progress_filename($uploaded_file); 203 205 204 if (!unlink($progress_filename)) { 205 print STDERR "Warning: Failed to delete $progress_filename\n"; 206 } 206 unlink($progress_filename) 207 unless $debugging_enabled; 207 208 208 209 my $fc_list = read_file_central(); 209 210 $fc_list = remove_from_file_central($uploaded_file,$fc_list); 210 211 write_file_central($fc_list); 212 } 213 214 215 sub unzip_archives_doc 216 { 217 my ($gsdl_cgi,$gsdl_home,$collect_home,$collect,$zip_filename) = @_; 218 219 my $lang_env = $gsdl_cgi->clean_param("lr") || ""; 220 221 my $import_dir = &util::filename_cat($collect_home,$collect,"import"); 222 223 # Unzip $zip_filename in the collection's import folder 224 my $java = $gsdl_cgi->get_java_path(); 225 my $jar_dir= &util::filename_cat($gsdl_home, "bin", "java"); 226 my $java_classpath = &util::filename_cat($jar_dir,"GLIServer.jar"); 227 228 my $java_args = "\"$zip_filename\" \"$import_dir\""; 229 230 $ENV{'LANG'} = $lang_env; 231 my $java_command = "\"$java\" -classpath \"$java_classpath\" org.greenstone.gatherer.remote.Unzip $java_args"; 232 233 my $java_output = `$java_command`; 234 my $java_status = $?; 235 if ($java_status > 0) { 236 my $report = "Java failed: $java_command\n--\n"; 237 $report .= "$java_output\n"; 238 $report .= "Exit status: " . ($java_status / 256) . "\n"; 239 $report .= $gsdl_cgi->check_java_home(); 240 241 $gsdl_cgi->generate_error($report); 242 } 243 else { 244 # Remove the zip file once we have unzipped it, since it is an intermediate file only 245 unlink($zip_filename) unless $debugging_enabled; 246 } 247 248 # print STDOUT "Content-type:text/plain\n\n"; 249 # print STDOUT "cmd = $java_command\n"; 250 # print STDOUT "**** $java_output\n"; 251 211 252 } 212 253 … … 223 264 224 265 my $gsdl_config = gsdlCGI->prenew(); 225 $gsdl_tmp_dir = &util::get_toplevel_tmp_dir(); 266 267 $gsdl_home = $gsdl_config->get_gsdl_home(); 268 $gsdl_tmp_dir = &util::get_toplevel_tmp_dir(); 226 269 227 270 require talkback; … … 240 283 if ($gsdl_cgi->param('process')) { 241 284 242 my $uploaded file = $gsdl_cgi->param('uploadedfile');243 my $full_filename = &util::filename_cat($gsdl_tmp_dir,$uploaded file);285 my $uploaded_file = $gsdl_cgi->param('uploadedfile'); 286 my $full_filename = &util::filename_cat($gsdl_tmp_dir,$uploaded_file); 244 287 245 288 my $done_html = &talkback::generate_done_html($full_filename); … … 247 290 if ($gsdl_cgi->param('yes_upload')) { 248 291 upload_file($gsdl_cgi,$full_filename); 292 293 my $collect = $gsdl_cgi->param('toCollect'); 294 my $collect_home = &util::filename_cat($gsdl_home,"collect"); 295 296 unzip_archives_doc($gsdl_cgi,$gsdl_home,$collect_home,$collect,$full_filename); 249 297 } 250 298 … … 252 300 print $done_html; 253 301 254 remove_progress_file($ gsdl_cgi->param('uploadedfile'));302 remove_progress_file($uploaded_file); 255 303 } 256 304 else { … … 262 310 my $uniq_file = $gsdl_cgi->param('uploadedfile'); 263 311 264 #my $uniq_file = "$collect-$oid-doc. xml";312 #my $uniq_file = "$collect-$oid-doc.zip"; 265 313 # Light-weight (hidden) form with progress bar 266 314
Note:
See TracChangeset
for help on using the changeset viewer.