Skip to content

Commit

Permalink
fix: Fixed image downscaler and document-factory with raw file checks…
Browse files Browse the repository at this point in the history
…um (#58)
  • Loading branch information
roadiz-ci committed Mar 4, 2025
1 parent 9347f27 commit 559a1bb
Show file tree
Hide file tree
Showing 3 changed files with 235 additions and 224 deletions.
13 changes: 8 additions & 5 deletions src/AbstractDocumentFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ public function getDocument(bool $allowEmpty = false, bool $allowDuplicates = fa
if (false !== $fileHash && !$allowDuplicates) {
$existingDocument = $this->documentFinder->findOneByHashAndAlgorithm($fileHash, $this->getHashAlgorithm());
if (null !== $existingDocument) {
if (
$existingDocument->isRaw()
&& null !== $existingDownscaledDocument = $existingDocument->getDownscaledDocument()
) {
/*
* If existing document is a RAW, serve its downscaled version
*/
if (null !== $existingDownscaledDocument = $existingDocument->getDownscaledDocument()) {
$existingDocument = $existingDownscaledDocument;
}
if (null !== $this->folder) {
Expand All @@ -139,7 +139,10 @@ public function getDocument(bool $allowEmpty = false, bool $allowDuplicates = fa
$this->logger->info(sprintf(
'File %s already exists with same checksum, do not upload it twice.',
$existingDocument->getFilename()
));
), [
'path' => $existingDocument->getMountPath(),
]);
(new Filesystem())->remove($file->getPathname());

return $existingDocument;
}
Expand Down
Loading

0 comments on commit 559a1bb

Please sign in to comment.