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

This commit is contained in:
Uwe Steinmann 2015-08-08 09:38:58 +02:00
commit 0735eb613f
2 changed files with 58 additions and 5 deletions

View File

@ -50,6 +50,39 @@ class SeedDMS_Preview_Previewer {
$this->width = intval($width);
}
static function execWithTimeout($cmd, $timeout=2) { /* {{{ */
$descriptorspec = array(
0 => array("pipe", "r"),
1 => array("pipe", "w"),
2 => array("pipe", "w")
);
$pipes = array();
$timeout += time();
$process = proc_open($cmd, $descriptorspec, $pipes);
if (!is_resource($process)) {
throw new Exception("proc_open failed on: " . $cmd);
}
$output = '';
do {
$timeleft = $timeout - time();
$read = array($pipes[1]);
stream_select($read, $write = NULL, $exeptions = NULL, $timeleft, NULL);
if (!empty($read)) {
$output .= fread($pipes[1], 8192);
}
} while (!feof($pipes[1]) && $timeleft > 0);
if ($timeleft <= 0) {
proc_terminate($process);
throw new Exception("command timeout on: " . $cmd);
} else {
return $output;
}
} /* }}} */
/**
* Retrieve the physical filename of the preview image on disk
*
@ -113,7 +146,11 @@ class SeedDMS_Preview_Previewer {
break;
}
if($cmd) {
exec($cmd);
//exec($cmd);
try {
self::execWithTimeout($cmd);
} catch(Exception $e) {
}
}
return true;
}

View File

@ -11,10 +11,10 @@
<email>uwe@steinmann.cx</email>
<active>yes</active>
</lead>
<date>2015-02-13</date>
<time>20:29:39</time>
<date>2015-08-08</date>
<time>09:36:57</time>
<version>
<release>1.1.3</release>
<release>1.1.4</release>
<api>1.1.0</api>
</version>
<stability>
@ -23,7 +23,7 @@
</stability>
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
<notes>
preview images will also be recreated if the object this image belongs is of newer date than the image itself. This happens if versions are being deleted and than a new version is uploaded. Because the new version will get the version number of the old version, it will also take over the old preview image.Comparing the creation date of the image with the object detects this case.
command for creating the preview will be called with a given timeout
</notes>
<contents>
<dir baseinstalldir="SeedDMS" name="/">
@ -115,5 +115,21 @@ add converters for .tar.gz, .ps, .txt
create fixed width image with proportional height
</notes>
</release>
<release>
<date>2015-02-13</date>
<time>20:29:39</time>
<version>
<release>1.1.3</release>
<api>1.1.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
<notes>
preview images will also be recreated if the object this image belongs is of newer date than the image itself. This happens if versions are being deleted and than a new version is uploaded. Because the new version will get the version number of the old version, it will also take over the old preview image.Comparing the creation date of the image with the object detects this case.
</notes>
</release>
</changelog>
</package>