mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-18 15:41:42 +00:00
timeout for external command can be passed to previewer
This commit is contained in:
parent
af4e6d46fb
commit
8bcca6a16a
|
@ -37,7 +37,13 @@ class SeedDMS_Preview_Previewer {
|
||||||
*/
|
*/
|
||||||
protected $width;
|
protected $width;
|
||||||
|
|
||||||
function __construct($previewDir, $width=40) {
|
/**
|
||||||
|
* @var integer $timeout maximum time for execution of external commands
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
protected $timeout;
|
||||||
|
|
||||||
|
function __construct($previewDir, $width=40, $timeout=5) {
|
||||||
if(!is_dir($previewDir)) {
|
if(!is_dir($previewDir)) {
|
||||||
if (!SeedDMS_Core_File::makeDir($previewDir)) {
|
if (!SeedDMS_Core_File::makeDir($previewDir)) {
|
||||||
$this->previewDir = '';
|
$this->previewDir = '';
|
||||||
|
@ -48,9 +54,10 @@ class SeedDMS_Preview_Previewer {
|
||||||
$this->previewDir = $previewDir;
|
$this->previewDir = $previewDir;
|
||||||
}
|
}
|
||||||
$this->width = intval($width);
|
$this->width = intval($width);
|
||||||
|
$this->timeout = intval($timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function execWithTimeout($cmd, $timeout=2) { /* {{{ */
|
static function execWithTimeout($cmd, $timeout=5) { /* {{{ */
|
||||||
$descriptorspec = array(
|
$descriptorspec = array(
|
||||||
0 => array("pipe", "r"),
|
0 => array("pipe", "r"),
|
||||||
1 => array("pipe", "w"),
|
1 => array("pipe", "w"),
|
||||||
|
@ -155,7 +162,7 @@ class SeedDMS_Preview_Previewer {
|
||||||
if($cmd) {
|
if($cmd) {
|
||||||
//exec($cmd);
|
//exec($cmd);
|
||||||
try {
|
try {
|
||||||
self::execWithTimeout($cmd);
|
self::execWithTimeout($cmd, $this->timeout);
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -216,7 +223,7 @@ class SeedDMS_Preview_Previewer {
|
||||||
if($cmd) {
|
if($cmd) {
|
||||||
//exec($cmd);
|
//exec($cmd);
|
||||||
try {
|
try {
|
||||||
self::execWithTimeout($cmd);
|
self::execWithTimeout($cmd, $this->timeout);
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user