/** * Check if the to be processed target file already exists * if exist take info from that file and mark task as done * * @param TaskInterface $task * @return bool */ protected function checkForExistingTargetFile(TaskInterface $task) { $processingFolder = $task->getTargetFile()->getStorage()->getProcessingFolder(); $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, '/'); $task->setExecuted(true); $imageDimensions = $this->getGraphicalFunctionsObject()->getImageDimensions($targetFile); $task->getTargetFile()->setName($task->getTargetFileName()); $properties = array('width' => $imageDimensions[0], 'height' => $imageDimensions[1], 'size' => filesize($targetFile), 'checksum' => $task->getConfigurationChecksum()); $task->getTargetFile()->updateProperties($properties); return true; } else { return false; } }
/** * Check if the to be processed target file already exists * if exist take info from that file and mark task as done * * @param TaskInterface $task * @return bool */ protected function checkForExistingTargetFile(TaskInterface $task) { // the storage of the processed file, not of the original file! $storage = $task->getTargetFile()->getStorage(); $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())) { // When the processed file already exists set it as processed file $task->getTargetFile()->setName($task->getTargetFileName()); // 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($task->getTargetFile(), false); $task->setExecuted(true); $imageDimensions = $this->getGraphicalFunctionsObject()->getImageDimensions($localProcessedFile); $properties = array('width' => $imageDimensions[0], 'height' => $imageDimensions[1], 'size' => filesize($localProcessedFile), 'checksum' => $task->getConfigurationChecksum()); $task->getTargetFile()->updateProperties($properties); return true; } else { return false; } }