$c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');
}
- public function makeTextsIndexes($book, $pages, &$index, &$textes, $simple = false)
+ public function makeTextsIndexes($book, $pages, &$index, &$textes, $simple = false, $force = false)
{
global $core;
$prefix = '';
- if ($book->parametres->textExtraction == 'poppler') {
+ if ($book->parametres->textExtraction === 'poppler') {
$prefix = 'p';
- } else if ($book->parametres->textExtraction == 'fluidbook') {
+ } else if ($book->parametres->textExtraction === 'fluidbook') {
$prefix = 'f';
}
$dir = WS_BOOKS . '/index/' . $book->book_id;
- if ($book->parametres->ignoreSearchSeparators != '') {
+ if ($book->parametres->ignoreSearchSeparators !== '') {
$dir .= '/' . sha1($book->parametres->ignoreSearchSeparators);
}
if (!file_exists($dir)) {
}
$tfilec = $dir . '/' . $prefix . 'textes.json';
- if (CubeIT_Util_Gzip::file_exists($ifilec) && CubeIT_Util_Gzip::file_exists($tfilec) && (min(CubeIT_Util_Gzip::filemtime($ifilec), CubeIT_Util_Gzip::filemtime($tfilec)) >= max($book->composition_update, filemtime(__FILE__), filemtime(WS_TOOLS . '/fwstk/out/artifacts/fwstk_jar/fwstk.jar')))) {
+ if (!$force && CubeIT_Util_Gzip::file_exists($ifilec) && CubeIT_Util_Gzip::file_exists($tfilec) && (min(CubeIT_Util_Gzip::filemtime($ifilec), CubeIT_Util_Gzip::filemtime($tfilec)) >= max($book->composition_update, filemtime(__FILE__), filemtime(WS_TOOLS . '/fwstk/out/artifacts/fwstk_jar/fwstk.jar')))) {
$index = CubeIT_Util_Gzip::file_get_contents($ifilec);
$textes = CubeIT_Util_Gzip::file_get_contents($tfilec);
+ if ($index === '[]') {
+ return $this->makeTextsIndexes($book, $pages, $index, $textes, $simple, true);
+ }
return;
}