mirror of
https://github.com/silverstripe/silverstripe-textextraction
synced 2024-10-22 11:06:00 +02:00
FIX Cleanup temporary file after extracting content in TikaServerTextExtractor and TikaTextExtractor
This commit is contained in:
parent
20079bd33f
commit
a9270d73ad
@ -127,6 +127,11 @@ class TikaServerTextExtractor extends FileTextExtractor
|
|||||||
public function getContent($file)
|
public function getContent($file)
|
||||||
{
|
{
|
||||||
$tempFile = $file instanceof File ? $this->getPathFromFile($file) : $file;
|
$tempFile = $file instanceof File ? $this->getPathFromFile($file) : $file;
|
||||||
return $this->getClient()->tika($tempFile);
|
$content = $this->getClient()->tika($tempFile);
|
||||||
|
//Cleanup temp file
|
||||||
|
if ($tempFile instanceof File) {
|
||||||
|
unlink($tempFile);
|
||||||
|
}
|
||||||
|
return $content;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,6 +80,10 @@ class TikaTextExtractor extends FileTextExtractor
|
|||||||
$path = $file instanceof File ? $this->getPathFromFile($file) : $file;
|
$path = $file instanceof File ? $this->getPathFromFile($file) : $file;
|
||||||
$command = sprintf('tika %s %s', $mode, escapeshellarg($path));
|
$command = sprintf('tika %s %s', $mode, escapeshellarg($path));
|
||||||
$code = $this->runShell($command, $output);
|
$code = $this->runShell($command, $output);
|
||||||
|
//Cleanup temp file
|
||||||
|
if ($path instanceof File) {
|
||||||
|
unlink($path);
|
||||||
|
}
|
||||||
|
|
||||||
if ($code == 0) {
|
if ($code == 0) {
|
||||||
return $output;
|
return $output;
|
||||||
|
Loading…
Reference in New Issue
Block a user