Avoid regenerating thumbnail or screenshot on edit

This commit is contained in:
automated-signal 2025-10-03 11:43:16 -05:00 committed by GitHub
commit 58c7af6c60
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -38,6 +38,7 @@ import {
import { missingCaseError } from '../util/missingCaseError.js';
import type { MakeVideoScreenshotResultType } from './VisualAttachment.js';
import type { MessageAttachmentType } from './AttachmentDownload.js';
import { strictAssert } from '../util/assert.js';
const {
isNumber,
@ -541,6 +542,11 @@ export async function captureDimensionsAndScreenshot(
const localUrl = getLocalAttachmentUrl(attachment);
if (GoogleChrome.isImageTypeSupported(contentType)) {
// Already generated thumbnail / width / height
if (attachment.thumbnail?.path) {
return attachment;
}
try {
const { width, height } = await getImageDimensionsFromURL({
objectUrl: localUrl,
@ -586,6 +592,16 @@ export async function captureDimensionsAndScreenshot(
}
}
strictAssert(
GoogleChrome.isVideoTypeSupported(contentType),
'enforced by early return'
);
// Already generated screenshot / width / height
if (attachment.screenshot?.path) {
return attachment;
}
let screenshotObjectUrl: string | undefined;
try {
const { blob, duration } = await makeVideoScreenshot({