generate video subdef in temporary path first

This commit is contained in:
aina-esokia
2018-06-15 15:51:10 +04:00
parent 9809e8f176
commit d306d292eb
2 changed files with 19 additions and 0 deletions

View File

@@ -67,6 +67,11 @@ class FilesystemService
return $pathdest . $this->generateSubdefFilename($record, $subdef);
}
public function generateTemporarySubdefPathname(\record_adapter $record, \databox_subdef $subdef, $tmpDir)
{
return $tmpDir . $this->generateSubdefFilename($record, $subdef);
}
/**
* @param RecordInterface $record
* @param string|\SplFileInfo $source

View File

@@ -22,6 +22,7 @@ use Alchemy\Phrasea\Filesystem\FilesystemService;
use Alchemy\Phrasea\Media\Subdef\Specification\PdfSpecification;
use MediaAlchemyst\Alchemyst;
use MediaAlchemyst\Specification\Image;
use MediaAlchemyst\Specification\Video;
use MediaVorus\MediaVorus;
use MediaAlchemyst\Exception\ExceptionInterface as MediaAlchemystException;
use Neutron\TemporaryFilesystem\Manager;
@@ -173,6 +174,14 @@ class SubdefGenerator
return;
}
$tmpDir = $this->app['conf']->get(['registry', 'executables', 'ffmpeg-tmp-directory']);
$destFile = null;
if($subdef_class->getSpecs() instanceof Video && !empty($tmpDir) && is_dir($tmpDir)){
$destFile = $pathdest;
$pathdest = $this->filesystem->generateTemporarySubdefPathname($record, $subdef_class, $tmpDir);
}
if (isset($this->tmpFilePath) && $subdef_class->getSpecs() instanceof Image) {
$this->alchemyst->turnInto($this->tmpFilePath, $pathdest, $subdef_class->getSpecs());
@@ -187,6 +196,11 @@ class SubdefGenerator
}
if($destFile){
$this->filesystem->copy($pathdest, $destFile);
$this->app['filesystem']->remove($pathdest);
}
} catch (MediaAlchemystException $e) {
$this->logger->error(sprintf('Subdef generation failed for record %d with message %s', $record->getRecordId(), $e->getMessage()));
}