Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(server): remove thumbnailAt in asset_job_status for missing thumbnails #12254

Merged
merged 2 commits into from
Sep 3, 2024

Conversation

mPyKen
Copy link
Contributor

@mPyKen mPyKen commented Sep 3, 2024

Similar to #12225, I realized some assets had thumbnailAt set, but had no thumbnail file in asset_files. In https://github.com/immich-app/immich/pull/11908/files#diff-99da4a5a2a767c94716e167a5d49f089778c22365cf403e92808711beb6125b9, thumbnailAt was set to NOW() if thumbnailPath IS NOT NULL, whereas asset_file was only created when "thumbnailPath" IS NOT NULL AND "thumbnailPath" != '' in https://github.com/immich-app/immich/pull/11861/files#diff-09097609a560037cd9fc82b6d5de63f184101d01c8d14a53182de0d5e649d4e0. This PR fixes actually missing thumbnails to be recognized as missing, again.

UPDATE "asset_job_status" j
SET "thumbnailAt" = NULL
WHERE j."thumbnailAt" IS NOT NULL
AND NOT EXISTS (
	SELECT 1 FROM public.asset_files f
	WHERE j."assetId" = f."assetId"
	AND f."type" = 'thumbnail'
	AND f."path" IS NOT NULL
)

@mertalev
Copy link
Contributor

mertalev commented Sep 3, 2024

Ugh, I hate empty strings... The same thing applies to previews, right? It'd be best to handle them too.

@mPyKen
Copy link
Contributor Author

mPyKen commented Sep 3, 2024

Interestingly, I didn't find such cases for previews in my db. I guess we managed not to create empty strings for previews so far. I can still add that migration if need be

@mertalev
Copy link
Contributor

mertalev commented Sep 3, 2024

Weirdly enough, the old preview column apparently defaulted to null while the thumbnail column defaulted to an empty string. I guess there's no need to handle it then.

@mertalev mertalev merged commit 4af8433 into immich-app:main Sep 3, 2024
23 checks passed
@mPyKen mPyKen deleted the fix-thumbat-wo-thumbs branch September 3, 2024 05:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants