Skip to content
Snippets Groups Projects
Commit efa96ba5 authored by Andreas Wolf's avatar Andreas Wolf Committed by Benni Mack
Browse files

[BUGFIX] LocalImageProcessor cannot reuse remote files

The LocalImageProcessor had a check for the storage type, to only do a
check for existing files on local storages, as it needed to fetch an
existing file from the storage to get metadata from it.

This check is now replaced by a proper usage of the FAL API: Fetch the
generated file for local (read-only) processing, which in case of a
local storage means the file is not moved at all. Then, the image
metadata can be extracted from the local file and the file index record
of the processed file can be updated accordingly.

Change-Id: I9fca326fe1d1743cd53a0a85c674ff81e5a051b9
Releases: master, 7.6
Resolves: #67126
Reviewed-on: https://review.typo3.org/46905


Reviewed-by: default avatarJan Helke <typo3@helke.de>
Tested-by: default avatarJan Helke <typo3@helke.de>
Reviewed-by: default avatarBenni Mack <benni@typo3.org>
Tested-by: default avatarBenni Mack <benni@typo3.org>
parent 4eae63bd
Branches
Tags
No related merge requests found
......@@ -106,26 +106,26 @@ class LocalImageProcessor implements ProcessorInterface
*/
protected function checkForExistingTargetFile(TaskInterface $task)
{
$processingFolder = $task->getTargetFile()->getStorage()->getProcessingFolder();
// the storage of the processed file, not of the original file!
$storage = $task->getTargetFile()->getStorage();
// @todo: make proper use of the FAL API, see https://forge.typo3.org/issues/67126
if ($processingFolder->hasFile($task->getTargetFileName()) && $storage->getDriverType() === 'Local') {
$processedFileIdentifier = rtrim($processingFolder->getIdentifier(), '/') . '/' . $task->getTargetFileName();
$configuration = $storage->getConfiguration();
if ($configuration['pathType'] === 'relative') {
$absoluteBasePath = PATH_site . $configuration['basePath'];
} else {
$absoluteBasePath = $configuration['basePath'];
}
$targetFile = $absoluteBasePath . ltrim($processedFileIdentifier, '/');
$processingFolder = $storage->getProcessingFolder();
// explicitly check for the raw filename here, as we check for files that existed before we even started
// processing, i.e. that were processed earlier
if ($processingFolder->hasFile($task->getTargetFileName())) {
// If the processed file already exists, fetch it and update its properties to reflect the actual file.
$processedFile = $storage->getFileInFolder($task->getTargetFileName(), $processingFolder);
// If the processed file is stored on a remote server, we must fetch a local copy of the file, as we
// have no API for fetching file metadata from a remote file.
$localProcessedFile = $storage->getFileForLocalProcessing($processedFile, false);
$task->setExecuted(true);
$imageDimensions = $this->getGraphicalFunctionsObject()->getImageDimensions($targetFile);
$imageDimensions = $this->getGraphicalFunctionsObject()->getImageDimensions($localProcessedFile);
$task->getTargetFile()->setName($task->getTargetFileName());
$properties = array(
'width' => $imageDimensions[0],
'height' => $imageDimensions[1],
'size' => filesize($targetFile),
'size' => filesize($localProcessedFile),
'checksum' => $task->getConfigurationChecksum()
);
$task->getTargetFile()->updateProperties($properties);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment