From 4a2d3f513feccc436d47929edeb034ed62e1dd35 Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Wed, 5 Aug 2026 09:42:44 -0700 Subject: [PATCH] snapshot: work around vips load crash during file truncation --- plugins/snapshot/src/image-reader.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/snapshot/src/image-reader.ts b/plugins/snapshot/src/image-reader.ts index 103351c9c..3cf998dca 100644 --- a/plugins/snapshot/src/image-reader.ts +++ b/plugins/snapshot/src/image-reader.ts @@ -1,3 +1,4 @@ +import fs from 'fs'; import sdk, { BufferConverter, Image, ImageOptions, MediaObject, MediaObjectOptions, ScryptedDeviceBase, ScryptedMimeTypes } from "@scrypted/sdk"; import type sharp from 'sharp'; import type { KernelEnum } from "sharp"; @@ -130,6 +131,10 @@ export class VipsImage implements Image { } export async function loadVipsMetadata(data: Buffer | string) { + if (typeof data === 'string') { + // if a file is deleted/truncated while being read, vips will seg fault. + data = await fs.promises.readFile(data); + } const image = sharpInstance(data, { failOn: 'none' });