Skip to content

Commit 7a73b1b

Browse files
author
roadiz-ci
committed
fix: Fixed image downscaler and document-factory with raw file checksum (#58)
1 parent b08998d commit 7a73b1b

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/Document/DocumentFinder.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ public function findOneByFilenames(array $fileNames): ?DocumentInterface
3434

3535
public function findOneByHashAndAlgorithm(string $hash, string $algorithm): ?DocumentInterface
3636
{
37-
return $this->getRepository()->findOneBy([
38-
'fileHash' => $hash,
39-
'fileHashAlgorithm' => $algorithm,
40-
]);
37+
return $this->getRepository()->findOneByHashAndAlgorithm($hash, $algorithm);
4138
}
4239

4340
protected function getRepository(): DocumentRepository

src/Repository/DocumentRepository.php

+12
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,18 @@ protected function getContextualQueryWithTranslation(
365365
return $qb;
366366
}
367367

368+
public function findOneByHashAndAlgorithm(string $hash, string $hashAlgorithm): ?Document
369+
{
370+
$qb = $this->createQueryBuilder('d');
371+
$qb->andWhere($qb->expr()->eq('d.fileHash', ':hash'))
372+
->andWhere($qb->expr()->eq('d.fileHashAlgorithm', ':hashAlgorithm'))
373+
->setParameter(':hash', $hash)
374+
->setParameter(':hashAlgorithm', $hashAlgorithm)
375+
->setMaxResults(1);
376+
377+
return $qb->getQuery()->getOneOrNullResult();
378+
}
379+
368380
/**
369381
* This method allows to pre-filter Documents with a given translation.
370382
*/

0 commit comments

Comments
 (0)