Index: openacs-4/packages/search/tcl/search-convert-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/tcl/search-convert-procs.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/search/tcl/search-convert-procs.tcl 27 Oct 2014 16:41:55 -0000 1.4 +++ openacs-4/packages/search/tcl/search-convert-procs.tcl 7 Aug 2017 23:48:29 -0000 1.5 @@ -22,6 +22,13 @@ @creation-date 2005-06-25 } { + if {[file size $filename] == 0} { + # + # Some conversion programs choke on empty content + # + return "" + } + set tmp_filename [ad_tmpnam] set result "" @@ -32,14 +39,14 @@ } application/msexcel - application/vnd.ms-excel { - set convert_command {xls2csv $filename >$tmp_filename} + set convert_command {xls2csv $filename >$tmp_filename 2> /dev/null} } application/mspowerpoint - application/vnd.ms-powerpoint { set convert_command {catppt $filename >$tmp_filename} } application/pdf { - set convert_command {pdftotext $filename $tmp_filename} + set convert_command {pdftotext -q $filename $tmp_filename} } application/vnd.oasis.opendocument.text - application/vnd.oasis.opendocument.text-template - @@ -52,7 +59,7 @@ set convert_command {unzip -p $filename content.xml >$tmp_filename} } text/html { - file delete $tmp_filename + file delete -- $tmp_filename # # Reading the whole content into memory is not necessarily # the best when dealing with huge files. However, for @@ -61,7 +68,7 @@ return [ns_striphtml [template::util::read_file $filename]] } text/plain { - file delete $tmp_filename + file delete -- $tmp_filename # # Reading the whole content into memory is not necessarily # the best when dealing with huge files. However, for @@ -78,17 +85,22 @@ } if {[catch {eval exec $convert_command} err]} { - catch {file delete $tmp_filename} + catch {file delete -- $tmp_filename} ns_log Error "SEARCH: conversion failed - $convert_command: $err" - file delete $tmp_filename return } set fd [open $tmp_filename "r"] set result [read $fd] close $fd - file delete $tmp_filename + file delete -- $tmp_filename return $result } + +# Local variables: +# mode: tcl +# tcl-indent-level: 4 +# indent-tabs-mode: nil +# End: