Read only the image from the selected cache

Using the instance from the list of cache, the ORM read the image for all the
linked cache which is unnecessary.

Closes #13831
(grafted from 4dd742a6d7cb8765364387d95fbc54c3ed86bce9)

--HG--
branch : 7.0
This commit is contained in:
Cédric Krier committed 2025-01-21 18:35:56 +01:00
1 parent 8f5dfc5b18
commit 3fcddd6029
2 files changed
+4 -2

No files matched your search

+2 -1
View File
@@ -166,7 +166,8 @@ class Image(ImageMixin, sequence_ordered(), ModelSQL, ModelView, MatchMixin):
raise ValueError("Invalid size")
for cache in self.cache:
if cache.size == size:
return cache.image
# re-instantiate to fetch only one image
return cache.__class__(cache.id).image
with Transaction().new_transaction():
cache = self._store_cache(size, self._resize(size))
# Save cache only if record is already committed