check if file to be indexed exists

This commit is contained in:
Uwe Steinmann 2019-12-31 15:42:15 +01:00
parent 8409b7e518
commit b7deb84279
2 changed files with 48 additions and 44 deletions

View File

@ -158,29 +158,31 @@ class SeedDMS_Lucene_IndexedDocument extends Zend_Search_Lucene_Document {
}
if($version && !$nocontent) {
$path = $dms->contentDir . $version->getPath();
$content = '';
$mimetype = $version->getMimeType();
$this->mimetype = $mimetype;
$cmd = '';
$mimeparts = explode('/', $mimetype, 2);
if(isset($_convcmd[$mimetype])) {
$cmd = sprintf($_convcmd[$mimetype], $path);
} elseif(isset($_convcmd[$mimeparts[0].'/*'])) {
$cmd = sprintf($_convcmd[$mimetype], $path);
} elseif(isset($_convcmd['*'])) {
$cmd = sprintf($_convcmd[$mimetype], $path);
}
if($cmd) {
$this->cmd = $cmd;
try {
$content = self::execWithTimeout($cmd, $timeout);
if($content['stdout']) {
$this->addField(Zend_Search_Lucene_Field::UnStored('content', $content['stdout'], 'utf-8'));
if(file_exists($path)) {
$content = '';
$mimetype = $version->getMimeType();
$this->mimetype = $mimetype;
$cmd = '';
$mimeparts = explode('/', $mimetype, 2);
if(isset($_convcmd[$mimetype])) {
$cmd = sprintf($_convcmd[$mimetype], $path);
} elseif(isset($_convcmd[$mimeparts[0].'/*'])) {
$cmd = sprintf($_convcmd[$mimetype], $path);
} elseif(isset($_convcmd['*'])) {
$cmd = sprintf($_convcmd[$mimetype], $path);
}
if($cmd) {
$this->cmd = $cmd;
try {
$content = self::execWithTimeout($cmd, $timeout);
if($content['stdout']) {
$this->addField(Zend_Search_Lucene_Field::UnStored('content', $content['stdout'], 'utf-8'));
}
if($content['stderr']) {
$this->errormsg = $content['stderr'];
}
} catch (Exception $e) {
}
if($content['stderr']) {
$this->errormsg = $content['stderr'];
}
} catch (Exception $e) {
}
}
}

View File

@ -152,29 +152,31 @@ class SeedDMS_SQLiteFTS_IndexedDocument extends SeedDMS_SQLiteFTS_Document {
}
if($version && !$nocontent) {
$path = $dms->contentDir . $version->getPath();
$content = '';
$mimetype = $version->getMimeType();
$this->mimetype = $mimetype;
$cmd = '';
$mimeparts = explode('/', $mimetype, 2);
if(isset($_convcmd[$mimetype])) {
$cmd = sprintf($_convcmd[$mimetype], $path);
} elseif(isset($_convcmd[$mimeparts[0].'/*'])) {
$cmd = sprintf($_convcmd[$mimetype], $path);
} elseif(isset($_convcmd['*'])) {
$cmd = sprintf($_convcmd[$mimetype], $path);
}
if($cmd) {
$this->cmd = $cmd;
try {
$content = self::execWithTimeout($cmd, $timeout);
if($content['stdout']) {
$this->addField('content', $content['stdout'], 'unstored');
if(file_exists($path)) {
$content = '';
$mimetype = $version->getMimeType();
$this->mimetype = $mimetype;
$cmd = '';
$mimeparts = explode('/', $mimetype, 2);
if(isset($_convcmd[$mimetype])) {
$cmd = sprintf($_convcmd[$mimetype], $path);
} elseif(isset($_convcmd[$mimeparts[0].'/*'])) {
$cmd = sprintf($_convcmd[$mimetype], $path);
} elseif(isset($_convcmd['*'])) {
$cmd = sprintf($_convcmd[$mimetype], $path);
}
if($cmd) {
$this->cmd = $cmd;
try {
$content = self::execWithTimeout($cmd, $timeout);
if($content['stdout']) {
$this->addField('content', $content['stdout'], 'unstored');
}
if($content['stderr']) {
$this->errormsg = $content['stderr'];
}
} catch (Exception $e) {
}
if($content['stderr']) {
$this->errormsg = $content['stderr'];
}
} catch (Exception $e) {
}
}
}