Merge branch 'seeddms-5.0.x' into seeddms-5.1.x

This commit is contained in:
Uwe Steinmann 2017-03-02 08:21:53 +01:00
commit 7e59084b25
9 changed files with 100 additions and 43 deletions

View File

@ -31,24 +31,25 @@ class SeedDMS_Lucene_IndexedDocument extends Zend_Search_Lucene_Document {
2 => array("pipe", "w") 2 => array("pipe", "w")
); );
$pipes = array(); $pipes = array();
$timeout += time(); $timeout += time();
$process = proc_open($cmd, $descriptorspec, $pipes); $process = proc_open($cmd, $descriptorspec, $pipes);
if (!is_resource($process)) { if (!is_resource($process)) {
throw new Exception("proc_open failed on: " . $cmd); throw new Exception("proc_open failed on: " . $cmd);
} }
$output = ''; $output = '';
$timeleft = $timeout - time();
$read = array($pipes[1]);
$write = NULL;
$exeptions = NULL;
do { do {
$timeleft = $timeout - time();
$read = array($pipes[1]);
$write = NULL;
$exeptions = NULL;
stream_select($read, $write, $exeptions, $timeleft, 200000); stream_select($read, $write, $exeptions, $timeleft, 200000);
if (!empty($read)) { if (!empty($read)) {
$output .= fread($pipes[1], 8192); $output .= fread($pipes[1], 8192);
} }
$timeleft = $timeout - time();
} while (!feof($pipes[1]) && $timeleft > 0); } while (!feof($pipes[1]) && $timeleft > 0);
if ($timeleft <= 0) { if ($timeleft <= 0) {
@ -127,19 +128,12 @@ class SeedDMS_Lucene_IndexedDocument extends Zend_Search_Lucene_Document {
$mimetype = $version->getMimeType(); $mimetype = $version->getMimeType();
if(isset($_convcmd[$mimetype])) { if(isset($_convcmd[$mimetype])) {
$cmd = sprintf($_convcmd[$mimetype], $path); $cmd = sprintf($_convcmd[$mimetype], $path);
$content = self::execWithTimeout($cmd, $timeout); try {
/* $content = self::execWithTimeout($cmd, $timeout);
$fp = popen($cmd, 'r'); if($content) {
if($fp) { $this->addField(Zend_Search_Lucene_Field::UnStored('content', $content, 'utf-8'));
$content = '';
while(!feof($fp)) {
$content .= fread($fp, 2048);
} }
pclose($fp); } catch (Exception $e) {
}
*/
if($content) {
$this->addField(Zend_Search_Lucene_Field::UnStored('content', $content, 'utf-8'));
} }
} }
} }

View File

@ -11,11 +11,11 @@
<email>uwe@steinmann.cx</email> <email>uwe@steinmann.cx</email>
<active>yes</active> <active>yes</active>
</lead> </lead>
<date>2016-04-28</date> <date>2017-03-01</date>
<time>08:11:19</time> <time>15:55:32</time>
<version> <version>
<release>1.1.9</release> <release>1.1.10</release>
<api>1.1.7</api> <api>1.1.10</api>
</version> </version>
<stability> <stability>
<release>stable</release> <release>stable</release>
@ -23,8 +23,7 @@
</stability> </stability>
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license> <license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
<notes> <notes>
pass variables to stream_select() to fullfill strict standards. catch exception in execWithTimeout()
make all functions in Indexer.php static
</notes> </notes>
<contents> <contents>
<dir baseinstalldir="SeedDMS" name="/"> <dir baseinstalldir="SeedDMS" name="/">
@ -235,5 +234,22 @@ add command for indexing postѕcript files
set last parameter of stream_select() to 200000 micro sec. in case the timeout in sec. is set to 0 set last parameter of stream_select() to 200000 micro sec. in case the timeout in sec. is set to 0
</notes> </notes>
</release> </release>
<release>
<date>2016-04-28</date>
<time>08:11:19</time>
<version>
<release>1.1.9</release>
<api>1.1.7</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
<notes>
pass variables to stream_select() to fullfill strict standards.
make all functions in Indexer.php static
</notes>
</release>
</changelog> </changelog>
</package> </package>

View File

@ -89,8 +89,13 @@ class SeedDMS_Preview_PdfPreviewer extends SeedDMS_Preview_Base {
$target = $this->previewDir.$dir.md5($infile); $target = $this->previewDir.$dir.md5($infile);
if($target != '' && (!file_exists($target.'.pdf') || filectime($target.'.pdf') < filectime($infile))) { if($target != '' && (!file_exists($target.'.pdf') || filectime($target.'.pdf') < filectime($infile))) {
$cmd = ''; $cmd = '';
$mimeparts = explode('/', $mimetype, 2);
if(isset($this->converters[$mimetype])) { if(isset($this->converters[$mimetype])) {
$cmd = str_replace(array('%f', '%o'), array($infile, $target.'.pdf'), $this->converters[$mimetype]); $cmd = str_replace(array('%f', '%o', '%m'), array($infile, $target.'.pdf', $mimetype), $this->converters[$mimetype]);
} elseif(isset($this->converters[$mimeparts[0].'/*'])) {
$cmd = str_replace(array('%f', '%o', '%m'), array($infile, $target.'.pdf', $mimetype), $this->converters[$mimeparts[0].'/*']);
} elseif(isset($this->converters['*'])) {
$cmd = str_replace(array('%f', '%o', '%m'), array($infile, $target.'.pdf', $mimetype), $this->converters['*']);
} }
if($cmd) { if($cmd) {
try { try {

View File

@ -106,9 +106,15 @@ class SeedDMS_Preview_Previewer extends SeedDMS_Preview_Base {
$target = $this->previewDir.$dir.md5($infile).'-'.$width; $target = $this->previewDir.$dir.md5($infile).'-'.$width;
if($target != '' && (!file_exists($target.'.png') || filectime($target.'.png') < filectime($infile))) { if($target != '' && (!file_exists($target.'.png') || filectime($target.'.png') < filectime($infile))) {
$cmd = ''; $cmd = '';
$mimeparts = explode('/', $mimetype, 2);
if(isset($this->converters[$mimetype])) { if(isset($this->converters[$mimetype])) {
$cmd = str_replace(array('%w', '%f', '%o'), array($width, $infile, $target.'.png'), $this->converters[$mimetype]); $cmd = str_replace(array('%w', '%f', '%o', '%m'), array($width, $infile, $target.'.png', $mimetype), $this->converters[$mimetype]);
} elseif(isset($this->converters[$mimeparts[0].'/*'])) {
$cmd = str_replace(array('%w', '%f', '%o', '%m'), array($width, $infile, $target.'.png', $mimetype), $this->converters[$mimeparts[0].'/*']);
} elseif(isset($this->converters['*'])) {
$cmd = str_replace(array('%w', '%f', '%o', '%m'), array($width, $infile, $target.'.png', $mimetype), $this->converters['*']);
} }
/* /*
switch($mimetype) { switch($mimetype) {
case "image/png": case "image/png":
@ -131,7 +137,6 @@ class SeedDMS_Preview_Previewer extends SeedDMS_Preview_Base {
} }
*/ */
if($cmd) { if($cmd) {
//exec($cmd);
try { try {
self::execWithTimeout($cmd, $this->timeout); self::execWithTimeout($cmd, $this->timeout);
} catch(Exception $e) { } catch(Exception $e) {

View File

@ -11,10 +11,10 @@
<email>uwe@steinmann.cx</email> <email>uwe@steinmann.cx</email>
<active>yes</active> <active>yes</active>
</lead> </lead>
<date>2016-11-15</date> <date>2017-03-02</date>
<time>21:00:26</time> <time>07:14:59</time>
<version> <version>
<release>1.2.1</release> <release>1.2.2</release>
<api>1.2.0</api> <api>1.2.0</api>
</version> </version>
<stability> <stability>
@ -23,7 +23,8 @@
</stability> </stability>
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license> <license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
<notes> <notes>
setConverters() overrides exiting converters commands can be set for mimetypes 'xxxx/*' and '*'
pass mimetype as parameter '%m' to converter
</notes> </notes>
<contents> <contents>
<dir baseinstalldir="SeedDMS" name="/"> <dir baseinstalldir="SeedDMS" name="/">
@ -254,5 +255,21 @@ check if cache dir exists before deleting it in deleteDocumentPreviews()
add new previewer which converts document to pdf instead of png add new previewer which converts document to pdf instead of png
</notes> </notes>
</release> </release>
<release>
<date>2016-11-15</date>
<time>21:00:26</time>
<version>
<release>1.2.1</release>
<api>1.2.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
<notes>
setConverters() overrides exiting converters
</notes>
</release>
</changelog> </changelog>
</package> </package>

View File

@ -37,7 +37,7 @@ class SeedDMS_SQLiteFTS_IndexedDocument extends SeedDMS_SQLiteFTS_Document {
); );
$pipes = array(); $pipes = array();
$timeout += time(); $timeout += time();
$process = proc_open($cmd, $descriptorspec, $pipes); $process = proc_open($cmd, $descriptorspec, $pipes);
if (!is_resource($process)) { if (!is_resource($process)) {
throw new Exception("proc_open failed on: " . $cmd); throw new Exception("proc_open failed on: " . $cmd);
@ -53,7 +53,7 @@ class SeedDMS_SQLiteFTS_IndexedDocument extends SeedDMS_SQLiteFTS_Document {
if (!empty($read)) { if (!empty($read)) {
$output .= fread($pipes[1], 8192); $output .= fread($pipes[1], 8192);
} }
$timeleft = $timeout - time(); $timeleft = $timeout - time();
} while (!feof($pipes[1]) && $timeleft > 0); } while (!feof($pipes[1]) && $timeleft > 0);
@ -133,9 +133,12 @@ class SeedDMS_SQLiteFTS_IndexedDocument extends SeedDMS_SQLiteFTS_Document {
$mimetype = $version->getMimeType(); $mimetype = $version->getMimeType();
if(isset($_convcmd[$mimetype])) { if(isset($_convcmd[$mimetype])) {
$cmd = sprintf($_convcmd[$mimetype], $path); $cmd = sprintf($_convcmd[$mimetype], $path);
$content = self::execWithTimeout($cmd, $timeout); try {
if($content) { $content = self::execWithTimeout($cmd, $timeout);
$this->addField('content', $content, 'unstored'); if($content) {
$this->addField('content', $content, 'unstored');
}
} catch (Exception $e) {
} }
} }
} }

View File

@ -11,11 +11,11 @@
<email>uwe@steinmann.cx</email> <email>uwe@steinmann.cx</email>
<active>yes</active> <active>yes</active>
</lead> </lead>
<date>2016-03-29</date> <date>2017-03-01</date>
<time>08:09:48</time> <time>15:53:24</time>
<version> <version>
<release>1.0.6</release> <release>1.0.7</release>
<api>1.0.1</api> <api>1.0.7</api>
</version> </version>
<stability> <stability>
<release>stable</release> <release>stable</release>
@ -23,7 +23,7 @@
</stability> </stability>
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license> <license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
<notes> <notes>
fix calculation of timeout (see bug #269) catch exception in execWithTimeout()
</notes> </notes>
<contents> <contents>
<dir baseinstalldir="SeedDMS" name="/"> <dir baseinstalldir="SeedDMS" name="/">
@ -162,5 +162,21 @@ make it work with sqlite3 &lt; 3.8.0
set last parameter of stream_select() to 200000 micro sec. in case the timeout in sec. is set to 0 set last parameter of stream_select() to 200000 micro sec. in case the timeout in sec. is set to 0
</notes> </notes>
</release> </release>
<release>
<date>2016-03-29</date>
<time>08:09:48</time>
<version>
<release>1.0.6</release>
<api>1.0.1</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
<notes>
fix calculation of timeout (see bug #269)
</notes>
</release>
</changelog> </changelog>
</package> </package>

View File

@ -188,7 +188,7 @@ if ($action == "saveSettings")
// SETTINGS - ADVANCED - INDEX CMD // SETTINGS - ADVANCED - INDEX CMD
$settings->_converters['fulltext'] = $_POST["converters"]; $settings->_converters['fulltext'] = $_POST["converters"];
$newmimetype = preg_replace('#[^A-Za-z0-9_/+.-]+#', '', $_POST["converters_newmimetype"]); $newmimetype = preg_replace('#[^A-Za-z0-9_/+.-*]+#', '', $_POST["converters_newmimetype"]);
if($newmimetype && trim($_POST["converters_newcmd"])) { if($newmimetype && trim($_POST["converters_newcmd"])) {
$settings->_converters['fulltext'][$newmimetype] = trim($_POST["converters_newcmd"]); $settings->_converters['fulltext'][$newmimetype] = trim($_POST["converters_newcmd"]);
} }

View File

@ -62,6 +62,7 @@ function check_queue() {
data: {command: 'indexdocument', id: docid}, data: {command: 'indexdocument', id: docid},
beforeSend: function() { beforeSend: function() {
queue_count++; // Add request to the counter queue_count++; // Add request to the counter
$('.queue-bar').css('width', (queue_count*100/MAX_REQUESTS)+'%');
}, },
error: function(xhr, textstatus) { error: function(xhr, textstatus) {
noty({ noty({