Handle invalid random photos before device writes and trace selections
This commit is contained in:
@@ -20,6 +20,7 @@ from pigway_frame_flow.models import StrictModel
|
||||
from pigway_frame_flow.providers.photo_names import path_caption
|
||||
from pigway_frame_flow.providers.photo_orientation import dimensions, orientation
|
||||
from pigway_frame_flow.providers.synology_photos import SynologyPhotos
|
||||
from pigway_frame_flow.renderers.images import MAX_IMAGE_PIXELS
|
||||
from pigway_frame_flow.settings import secret
|
||||
from pigway_frame_flow.storage.database import encode
|
||||
|
||||
@@ -319,7 +320,7 @@ class PhotoSources:
|
||||
if allowed is not None and relative not in allowed:
|
||||
continue
|
||||
info = {}
|
||||
if wanted:
|
||||
if wanted or source.kind == "local":
|
||||
key = str(path)
|
||||
stamp = path.stat()
|
||||
cached_size = sizes.get(key)
|
||||
@@ -334,8 +335,17 @@ class PhotoSources:
|
||||
)
|
||||
else:
|
||||
size = dimensions(root, path)
|
||||
if size is None and preview:
|
||||
preview_path = self.thumbnail(path)
|
||||
size = (
|
||||
dimensions(root, preview_path)
|
||||
if preview_path
|
||||
else None
|
||||
)
|
||||
if size is None:
|
||||
continue
|
||||
if wanted:
|
||||
continue
|
||||
size = (0, 0)
|
||||
width, height = size
|
||||
size_updates.append(
|
||||
(
|
||||
@@ -347,13 +357,21 @@ class PhotoSources:
|
||||
)
|
||||
)
|
||||
direction = orientation(width, height)
|
||||
if direction != wanted:
|
||||
if wanted and direction != wanted:
|
||||
continue
|
||||
info = {
|
||||
"width": width,
|
||||
"height": height,
|
||||
"orientation": direction,
|
||||
}
|
||||
if width * height > MAX_IMAGE_PIXELS:
|
||||
if (
|
||||
source.synology_previews
|
||||
and self.thumbnail(path) is not None
|
||||
):
|
||||
preview = True
|
||||
else:
|
||||
continue
|
||||
items.append(
|
||||
{
|
||||
**info,
|
||||
|
||||
Reference in New Issue
Block a user