From c2a9506b4855f67d320eb479a67800098d73e8ec Mon Sep 17 00:00:00 2001 From: KernelDeimos Date: Tue, 8 Oct 2024 01:41:18 -0400 Subject: [PATCH] fix: thumbnail service updates --- src/backend/src/CoreModule.js | 1 + src/backend/src/filesystem/hl_operations/hl_write.js | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/backend/src/CoreModule.js b/src/backend/src/CoreModule.js index 67a05030..b54c8d11 100644 --- a/src/backend/src/CoreModule.js +++ b/src/backend/src/CoreModule.js @@ -219,6 +219,7 @@ const install = async ({ services, app, useapi }) => { services.registerService('counting', ConfigurableCountingService); services.registerService('thumbnails', StrategizedService, { strategy_key: 'engine', + default_strategy: 'purejs', strategies: { napi: [NAPIThumbnailService], purejs: [PureJSThumbnailService], diff --git a/src/backend/src/filesystem/hl_operations/hl_write.js b/src/backend/src/filesystem/hl_operations/hl_write.js index b6b439ac..4744040a 100644 --- a/src/backend/src/filesystem/hl_operations/hl_write.js +++ b/src/backend/src/filesystem/hl_operations/hl_write.js @@ -24,7 +24,7 @@ const UserParam = require("../../api/filesystem/UserParam"); const config = require("../../config"); const { chkperm, validate_fsentry_name } = require("../../helpers"); const { TeePromise } = require("../../util/promise"); -const { pausing_tee, logging_stream, offset_write_stream } = require("../../util/streamutil"); +const { pausing_tee, logging_stream, offset_write_stream, stream_to_the_void } = require("../../util/streamutil"); const { TYPE_DIRECTORY } = require("../FSNodeContext"); const { LLRead } = require("../ll_operations/ll_read"); const { RootNodeSelector, NodePathSelector } = require("../node/selectors"); @@ -299,7 +299,7 @@ class HLWrite extends HLFilesystemOperation { this.checkpoint('before thumbnail'); let thumbnail_promise = new TeePromise(); - let thumbnail; (async () => { + (async () => { const reason = await (async () => { const { mime } = this.modules; const thumbnails = context.get('services').get('thumbnails'); @@ -324,7 +324,13 @@ class HLWrite extends HLFilesystemOperation { return { ...values.file, stream: thumbnail_stream }; })(); - thumbnail = await thumbnails.thumbify(thumb_file); + let thumbnail; + try { + thumbnail = await thumbnails.thumbify(thumb_file); + } catch (e) { + stream_to_the_void(thumb_file.stream); + return 'thumbnail error: ' + e.message; + } thumbnail_promise.resolve(thumbnail); })(); if ( reason ) {