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) { if($version && !$nocontent) {
$path = $dms->contentDir . $version->getPath(); $path = $dms->contentDir . $version->getPath();
$content = ''; if(file_exists($path)) {
$mimetype = $version->getMimeType(); $content = '';
$this->mimetype = $mimetype; $mimetype = $version->getMimeType();
$cmd = ''; $this->mimetype = $mimetype;
$mimeparts = explode('/', $mimetype, 2); $cmd = '';
if(isset($_convcmd[$mimetype])) { $mimeparts = explode('/', $mimetype, 2);
$cmd = sprintf($_convcmd[$mimetype], $path); if(isset($_convcmd[$mimetype])) {
} elseif(isset($_convcmd[$mimeparts[0].'/*'])) { $cmd = sprintf($_convcmd[$mimetype], $path);
$cmd = sprintf($_convcmd[$mimetype], $path); } elseif(isset($_convcmd[$mimeparts[0].'/*'])) {
} elseif(isset($_convcmd['*'])) { $cmd = sprintf($_convcmd[$mimetype], $path);
$cmd = sprintf($_convcmd[$mimetype], $path); } elseif(isset($_convcmd['*'])) {
} $cmd = sprintf($_convcmd[$mimetype], $path);
if($cmd) { }
$this->cmd = $cmd; if($cmd) {
try { $this->cmd = $cmd;
$content = self::execWithTimeout($cmd, $timeout); try {
if($content['stdout']) { $content = self::execWithTimeout($cmd, $timeout);
$this->addField(Zend_Search_Lucene_Field::UnStored('content', $content['stdout'], 'utf-8')); 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) { if($version && !$nocontent) {
$path = $dms->contentDir . $version->getPath(); $path = $dms->contentDir . $version->getPath();
$content = ''; if(file_exists($path)) {
$mimetype = $version->getMimeType(); $content = '';
$this->mimetype = $mimetype; $mimetype = $version->getMimeType();
$cmd = ''; $this->mimetype = $mimetype;
$mimeparts = explode('/', $mimetype, 2); $cmd = '';
if(isset($_convcmd[$mimetype])) { $mimeparts = explode('/', $mimetype, 2);
$cmd = sprintf($_convcmd[$mimetype], $path); if(isset($_convcmd[$mimetype])) {
} elseif(isset($_convcmd[$mimeparts[0].'/*'])) { $cmd = sprintf($_convcmd[$mimetype], $path);
$cmd = sprintf($_convcmd[$mimetype], $path); } elseif(isset($_convcmd[$mimeparts[0].'/*'])) {
} elseif(isset($_convcmd['*'])) { $cmd = sprintf($_convcmd[$mimetype], $path);
$cmd = sprintf($_convcmd[$mimetype], $path); } elseif(isset($_convcmd['*'])) {
} $cmd = sprintf($_convcmd[$mimetype], $path);
if($cmd) { }
$this->cmd = $cmd; if($cmd) {
try { $this->cmd = $cmd;
$content = self::execWithTimeout($cmd, $timeout); try {
if($content['stdout']) { $content = self::execWithTimeout($cmd, $timeout);
$this->addField('content', $content['stdout'], 'unstored'); 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) {
} }
} }
} }